From 65edade6f5e70d36009bd468b21b6774f1d86422 Mon Sep 17 00:00:00 2001 From: Dave West Date: Fri, 30 Nov 2007 19:12:30 +0000 Subject: [PATCH] ctdl_thread_internal_gc() now follows rule for critical_section --- citadel/server_main.c | 6 ++++++ citadel/sysdep.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/citadel/server_main.c b/citadel/server_main.c index a18c50266..67102a206 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -354,9 +354,15 @@ int main(int argc, char **argv) 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 diff --git a/citadel/sysdep.c b/citadel/sysdep.c index dafe4536c..5f27ad681 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -1517,7 +1517,6 @@ void ctdl_internal_thread_gc (void) /* * Woke up to do garbage collection */ - begin_critical_section(S_THREAD_LIST); this_thread = CtdlThreadList; while(this_thread) { @@ -1534,7 +1533,6 @@ void ctdl_internal_thread_gc (void) 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; @@ -1542,7 +1540,6 @@ void ctdl_internal_thread_gc (void) 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; @@ -1582,14 +1579,12 @@ void ctdl_internal_thread_gc (void) /* 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); } -- 2.39.2