]> code.citadel.org Git - citadel.git/blobdiff - citadel/threads.c
sleep() isn't defined to be per thread; use usleep() instead which is.
[citadel.git] / citadel / threads.c
index 965f866da2c31c44000988c8b3caf484c52d4aa3..a9fce4eb471282f59e5cbaf1ff5831496e9c3237 100644 (file)
@@ -157,6 +157,7 @@ void *CTC_backend(void *supplied_start_routine)
 
        start_routine(NULL);
 
+       free(mytsd);
        return(NULL);
 }
 
@@ -196,8 +197,6 @@ void go_threading(void)
        /* Second call to module init functions now that threading is up */
        initialise_modules(1);
 
-       CtdlThreadCreate(select_on_master);
-
        /* Begin with one worker thread.  We will expand the pool if necessary */
        CtdlThreadCreate(worker_thread);
 
@@ -208,7 +207,7 @@ void go_threading(void)
                if ((active_workers == num_workers) && (num_workers < 256)) {
                        CtdlThreadCreate(worker_thread);
                }
-               sleep(1);
+               usleep(1000);
        }
 
        /* When we get to this point we are getting ready to shut down our Citadel server */
@@ -217,9 +216,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);
-               sleep(1);
+               syslog(LOG_DEBUG, "Waiting %d seconds for %d worker threads to exit",
+                       countdown, num_workers
+               );
+               usleep(1000);
        }
 }