Prevent the creation of new threads if system load climbs at shutdown
[citadel.git] / citadel / server_main.c
index 343d0ae13b2daffce1cf72aad7fffe9f32d7c4bd..27942365d7ba7cd90aa37c0e6dcd794de8b6fda8 100644 (file)
@@ -347,15 +347,10 @@ void go_threading(void)
        int i;
        struct CtdlThreadNode *last_worker;
        
-       /* We can't use CT_PUSH() here so we do it the long way 
-        * So we can still use CT for current thread */
-       struct CtdlThreadNode *_this_cit_thread;
-       
        /*
         * Initialise the thread system
         */
        ctdl_thread_internal_init();
-       _this_cit_thread = CtdlThreadSelf();
        /*
         * Now create a bunch of worker threads.
         */
@@ -431,7 +426,7 @@ void go_threading(void)
                 */
 //             if ((CtdlThreadGetWorkers() < config.c_max_workers) && (CtdlThreadGetWorkers() < num_sessions))
                // && (CtdlThreadLoadAvg < 90) )
-               if ((CtdlThreadGetWorkers() < config.c_max_workers) && (CtdlThreadGetWorkerAvg() > 60) && (CtdlThreadGetLoadAvg() < 90) )
+               if ((CtdlThreadGetWorkers() < config.c_max_workers) && (CtdlThreadGetWorkerAvg() > 60) && (CtdlThreadGetLoadAvg() < 90) && (CT->state > CTDL_THREAD_STOP_REQ))
                {
                        for (i=0; i<5 ; i++)
 //                     for (i=0; i< (num_sessions - CtdlThreadGetWorkers()) ; i++)