Skip to content

Commit

Permalink
1. 修正http接收的超时判断。
Browse files Browse the repository at this point in the history
2. list_remove增加list长度判断。
  • Loading branch information
yougaliu committed Aug 26, 2019
1 parent ef3263b commit 13cc46c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/utils/farra/utils_httpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ static int _http_client_recv(HTTPClient *client, char *buf, int min_len, int max
else if (rc == QCLOUD_ERR_SSL_READ_TIMEOUT || rc == QCLOUD_ERR_TCP_READ_TIMEOUT) {
if (*p_read_len == client_data->retrieve_len || client_data->retrieve_len == 0)
rc = QCLOUD_ERR_SUCCESS;
else
Log_e("network_stack read timeout");
}
else if (rc == QCLOUD_ERR_TCP_PEER_SHUTDOWN && *p_read_len > 0) {
/* HTTP server give response and close this connection */
Expand Down Expand Up @@ -424,9 +426,11 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len

if (rc != QCLOUD_ERR_SUCCESS) {
IOT_FUNC_EXIT_RC(rc);
}else if(0 == left_ms(&timer)){
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
}
}
if (0 == left_ms(&timer)) {
Log_e("HTTP read timeout!");
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
}

if (len == 0) {
/* read no more data */
Expand Down Expand Up @@ -532,8 +536,10 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
rc = _http_client_recv(client, data, 1, max_len, &len, left_ms(&timer), client_data);
if (rc != QCLOUD_ERR_SUCCESS) {
IOT_FUNC_EXIT_RC(rc);
}else if(0 == left_ms(&timer)){
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
}
if (left_ms(&timer) == 0) {
Log_e("HTTP read timeout!");
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
}
}
} while (readLen);
Expand Down Expand Up @@ -724,9 +730,7 @@ static int _http_client_recv_response(HTTPClient *client, uint32_t timeout_ms, H

if (rc != QCLOUD_ERR_SUCCESS) {
IOT_FUNC_EXIT_RC(rc);
}else if(0 == left_ms(&timer)){
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
}
}

buf[reclen] = '\0';

Expand Down
3 changes: 2 additions & 1 deletion src/utils/farra/utils_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ void list_remove(List *self, ListNode *node)
}

HAL_Free(node);
--self->len;
if (self->len)
--self->len;
}

/*
Expand Down

0 comments on commit 13cc46c

Please sign in to comment.