ctdl_thread_internal_calc_loadavg();
end_critical_section(S_THREAD_LIST);
CtdlThreadSleep(1);
+ begin_critical_section(S_THREAD_LIST);
ctdl_internal_thread_gc();
+ end_critical_section(S_THREAD_LIST);
if (CtdlThreadGetCount() <= 1) // Shutting down clean up the garbage collector
+ {
+ begin_critical_section(S_THREAD_LIST);
ctdl_internal_thread_gc();
+ end_critical_section(S_THREAD_LIST);
+ }
}
/*
* If the above loop exits we must be shutting down since we obviously have no threads
/*
* Woke up to do garbage collection
*/
- begin_critical_section(S_THREAD_LIST);
this_thread = CtdlThreadList;
while(this_thread)
{
if (pthread_equal(that_thread->tid, pthread_self()) && that_thread->thread_func)
{ /* Sanity check */
- end_critical_section(S_THREAD_LIST);
CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, a thread is trying to clean up after itself.\n");
CtdlThreadStopAll();
return;
if (num_threads <= 0)
{ /* Sanity check */
- end_critical_section (S_THREAD_LIST);
CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, num_threads <= 0 and trying to do Garbage Collection.\n");
CtdlThreadStopAll();
return;
/* Sanity check number of worker threads */
if (workers != num_workers)
{
- end_critical_section(S_THREAD_LIST);
CtdlLogPrintf(CTDL_WARNING,
"Thread system WARNING, discrepancy in number of worker threads. Counted %d, should be %d.\n",
workers, num_workers
);
return;
}
- end_critical_section(S_THREAD_LIST);
}