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.
*/
if (exit_signal)
CtdlThreadStopAll();
check_sched_shutdown();
- begin_critical_section(S_THREAD_LIST);
- ctdl_thread_internal_calc_loadavg();
- end_critical_section(S_THREAD_LIST);
-
+ if (CT->state > CTDL_THREAD_STOP_REQ)
+ {
+ begin_critical_section(S_THREAD_LIST);
+ ctdl_thread_internal_calc_loadavg();
+ end_critical_section(S_THREAD_LIST);
+
+ ctdl_thread_internal_check_scheduled(); /* start scheduled threads */
+ }
+
/* Reduce the size of the worker thread pool if necessary. */
- if ((CtdlThreadGetWorkers() > config.c_min_workers) && (CtdlThreadWorkerAvg < 20))
+ if ((CtdlThreadGetWorkers() > config.c_min_workers) && (CtdlThreadWorkerAvg < 20) && (CT->state > CTDL_THREAD_STOP_REQ))
{
/* Ask a worker thread to stop as we no longer need it */
begin_critical_section(S_THREAD_LIST);
*/
// 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++)