Decrement num_workers when exiting worker_thread() under _any_ circumstances.
authorArt Cancro <ajc@citadel.org>
Mon, 21 Mar 2011 15:02:19 +0000 (11:02 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 17:17:03 +0000 (17:17 +0000)
This allows system shutdown to proceed normally.

citadel/sysdep.c
citadel/threads.c

index ea89f5ac5e9e3865be37c6c8111f6a0d1a61030d..9f1425bb2ac55b4011ebfb85955c2b2e70da09b4 100644 (file)
@@ -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
index 965f866da2c31c44000988c8b3caf484c52d4aa3..eda189281c83ad572183fb60482fb26948b3d8db 100644 (file)
@@ -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);
        }
 }