From 6172b4b706da92b14ca6b805ec17c4dac7b51d9f Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 3 Sep 2019 02:19:00 +0000 Subject: [PATCH] Alterego reported a scenario where the web server's cleanup() would wait forever for 1 child thread (presumably the http_logging_thread) to terminate: > 8/27 02:39:43p Waiting for HTTP logging thread to terminate... > 8/27 02:39:43p HTTP logging thread started > 8/27 02:39:43p HTTP logging thread received NULL linked list log entry > 8/27 02:40:44p !TIMEOUT waiting for HTTP logging thread to terminate > 8/27 02:40:44p Done waiting for HTTP logging thread to terminate > 8/27 02:40:44p 0000 Waiting for 1 child threads to terminate <infinite wait loop here> - Add an extra terminate_http_logging_thread check to the top of the loop in http_logging_thread(). - Signal the log_list semaphore in the "Waiting for HTTP logging thread" and "Waiting for x child threads" loops. --- src/sbbs3/websrvr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c index 63c6dd839c..2cc684acfa 100644 --- a/src/sbbs3/websrvr.c +++ b/src/sbbs3/websrvr.c @@ -6533,6 +6533,7 @@ static void cleanup(int code) lprintf(LOG_INFO,"0000 Waiting for %d child threads to terminate", protected_uint32_value(thread_count)-1); while(protected_uint32_value(thread_count) > 1) { mswait(100); + listSemPost(&log_list); } lprintf(LOG_INFO,"0000 Done waiting"); } @@ -6620,7 +6621,7 @@ void http_logging_thread(void* arg) lprintf(LOG_INFO,"HTTP logging thread started"); - for(;;) { + while(!terminate_http_logging_thread) { struct log_data *ld; char timestr[128]; char sizestr[100]; @@ -7086,6 +7087,7 @@ void DLLCALL web_server(void* arg) "terminate"); break; } + listSemPost(&log_list); mswait(100); } lprintf(LOG_INFO, "Done waiting for HTTP logging thread to terminate"); -- GitLab