From: Art Cancro Date: Mon, 21 Mar 2011 15:02:19 +0000 (-0400) Subject: Decrement num_workers when exiting worker_thread() under _any_ circumstances. X-Git-Tag: v8.11~809 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=8d94f7585e451d323e7168a23fdaf691c96ca95f Decrement num_workers when exiting worker_thread() under _any_ circumstances. This allows system shutdown to proceed normally. --- diff --git a/citadel/sysdep.c b/citadel/sysdep.c index ea89f5ac5..9f1425bb2 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -1200,6 +1200,7 @@ do_select: force_purge = 0; retval = select(highest + 1, &readfds, NULL, NULL, &tv); } else { + --num_workers; return NULL; } @@ -1219,12 +1220,18 @@ do_select: force_purge = 0; #if 0 syslog(LOG_DEBUG, "Interrupted select()\n"); #endif - if (server_shutting_down) return(NULL); + if (server_shutting_down) { + --num_workers; + return(NULL); + } goto do_select; } } else if (retval == 0) { - if (server_shutting_down) return(NULL); + if (server_shutting_down) { + --num_workers; + return(NULL); + } } /* It must be a client socket. Find a context that has data diff --git a/citadel/threads.c b/citadel/threads.c index 965f866da..eda189281 100644 --- a/citadel/threads.c +++ b/citadel/threads.c @@ -217,9 +217,11 @@ void go_threading(void) CtdlShutdownServiceHooks(); /* close all listener sockets to prevent new connections */ PerformSessionHooks(EVT_SHUTDOWN); /* run any registered shutdown hooks */ - int countdown = 10; + int countdown = 30; while ( (num_workers > 0) && (countdown-- > 0)) { - syslog(LOG_DEBUG, "Waiting for %d worker threads to exit", num_workers); + syslog(LOG_DEBUG, "Waiting %d seconds for %d worker threads to exit", + countdown, num_workers + ); sleep(1); } }