Skip to content

Commit 13cc46c

Browse files
author
yougaliu
committed
1. 修正http接收的超时判断。
2. list_remove增加list长度判断。
1 parent ef3263b commit 13cc46c

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/utils/farra/utils_httpc.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ static int _http_client_recv(HTTPClient *client, char *buf, int min_len, int max
374374
else if (rc == QCLOUD_ERR_SSL_READ_TIMEOUT || rc == QCLOUD_ERR_TCP_READ_TIMEOUT) {
375375
if (*p_read_len == client_data->retrieve_len || client_data->retrieve_len == 0)
376376
rc = QCLOUD_ERR_SUCCESS;
377+
else
378+
Log_e("network_stack read timeout");
377379
}
378380
else if (rc == QCLOUD_ERR_TCP_PEER_SHUTDOWN && *p_read_len > 0) {
379381
/* HTTP server give response and close this connection */
@@ -424,9 +426,11 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
424426

425427
if (rc != QCLOUD_ERR_SUCCESS) {
426428
IOT_FUNC_EXIT_RC(rc);
427-
}else if(0 == left_ms(&timer)){
428-
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
429-
}
429+
}
430+
if (0 == left_ms(&timer)) {
431+
Log_e("HTTP read timeout!");
432+
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
433+
}
430434

431435
if (len == 0) {
432436
/* read no more data */
@@ -532,8 +536,10 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
532536
rc = _http_client_recv(client, data, 1, max_len, &len, left_ms(&timer), client_data);
533537
if (rc != QCLOUD_ERR_SUCCESS) {
534538
IOT_FUNC_EXIT_RC(rc);
535-
}else if(0 == left_ms(&timer)){
536-
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
539+
}
540+
if (left_ms(&timer) == 0) {
541+
Log_e("HTTP read timeout!");
542+
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
537543
}
538544
}
539545
} while (readLen);
@@ -724,9 +730,7 @@ static int _http_client_recv_response(HTTPClient *client, uint32_t timeout_ms, H
724730

725731
if (rc != QCLOUD_ERR_SUCCESS) {
726732
IOT_FUNC_EXIT_RC(rc);
727-
}else if(0 == left_ms(&timer)){
728-
IOT_FUNC_EXIT_RC(QCLOUD_ERR_HTTP_TIMEOUT);
729-
}
733+
}
730734

731735
buf[reclen] = '\0';
732736

src/utils/farra/utils_list.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ void list_remove(List *self, ListNode *node)
228228
}
229229

230230
HAL_Free(node);
231-
--self->len;
231+
if (self->len)
232+
--self->len;
232233
}
233234

234235
/*

0 commit comments

Comments
 (0)