From b1f2b415541d952ee79d29a71140294856ea6187 Mon Sep 17 00:00:00 2001 From: TheSomeMan Date: Sat, 17 Feb 2024 00:51:12 +0700 Subject: [PATCH 1/2] Fix #282: Task watchdog triggers on full load test --- src/http_server_accept_and_handle_conn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/http_server_accept_and_handle_conn.c b/src/http_server_accept_and_handle_conn.c index 2e329bd..6c3c78f 100644 --- a/src/http_server_accept_and_handle_conn.c +++ b/src/http_server_accept_and_handle_conn.c @@ -423,13 +423,21 @@ write_content_from_json_generator(struct netconn* const p_conn, const http_serve { netconn_flags |= (uint8_t)NETCONN_MORE; } - LOG_INFO("json_stream_gen: send %u bytes:\n%s", num_bytes, p_chunk); + if (p_resp->content_len < 4 * 1024) + { + LOG_INFO("json_stream_gen: send %u bytes:\n%s", num_bytes, p_chunk); + } + else + { + LOG_DBG("json_stream_gen: send %u bytes:\n%s", num_bytes, p_chunk); + } const bool res = http_server_netconn_write(p_conn, p_chunk, num_bytes, netconn_flags); if (!res) { LOG_ERR("%s failed", "http_server_netconn_write"); break; } + vTaskDelay(pdMS_TO_TICKS(5)); } json_stream_gen_delete(&p_json_gen); } From a8c824acd771b9690f978b5a842307ea2cd7eefb Mon Sep 17 00:00:00 2001 From: TheSomeMan Date: Mon, 19 Feb 2024 18:11:47 +0700 Subject: [PATCH 2/2] [#282] Add comments, defines, fix issues found by SonarCloud --- src/http_server_accept_and_handle_conn.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/http_server_accept_and_handle_conn.c b/src/http_server_accept_and_handle_conn.c index 6c3c78f..c2bdb50 100644 --- a/src/http_server_accept_and_handle_conn.c +++ b/src/http_server_accept_and_handle_conn.c @@ -23,7 +23,10 @@ #define FULLBUF_SIZE (4U * 1024U) -#define HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG (256U) +#define HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FOR_JSON_RESP (256U) +#define HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FROM_JSON_GENERATOR (4U * 1024U) + +#define HTTP_SERVER_DELAY_BETWEEN_NETCONN_WRITE_MS (5) #define HTTP_HEADER_DATE_EXAMPLE "Date: Thu, 01 Jan 2021 00:00:00 GMT\r\n" @@ -423,7 +426,7 @@ write_content_from_json_generator(struct netconn* const p_conn, const http_serve { netconn_flags |= (uint8_t)NETCONN_MORE; } - if (p_resp->content_len < 4 * 1024) + if (p_resp->content_len < HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FROM_JSON_GENERATOR) { LOG_INFO("json_stream_gen: send %u bytes:\n%s", num_bytes, p_chunk); } @@ -437,7 +440,7 @@ write_content_from_json_generator(struct netconn* const p_conn, const http_serve LOG_ERR("%s failed", "http_server_netconn_write"); break; } - vTaskDelay(pdMS_TO_TICKS(5)); + vTaskDelay(pdMS_TO_TICKS(HTTP_SERVER_DELAY_BETWEEN_NETCONN_WRITE_MS)); // A delay to avoid triggering watchdog } json_stream_gen_delete(&p_json_gen); } @@ -908,7 +911,7 @@ http_server_netconn_serve_handle_req( || (HTTP_CONTENT_LOCATION_HEAP == resp.content_location))) { const size_t content_len = strlen((const char*)resp.select_location.memory.p_buf); - if (content_len <= HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG) + if (content_len <= HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FOR_JSON_RESP) { LOG_INFO("Json resp: code=%u, content:\n%s", resp.http_resp_code, resp.select_location.memory.p_buf); }