use the gnu format string checker for CtdlLogPrintf; fix associated new warnings...
[citadel.git] / citadel / threads.c
index ec64ceaefb4407b345ed5858cb010e4f15a093ae..0dcf4c38e8e4c255a98bc23e3cde03cf14a988f7 100644 (file)
@@ -58,6 +58,7 @@
 #include "citserver.h"
 #include "sysdep_decls.h"
 #include "context.h"
+#include "event_client.h"
 
 /*
  * define this to use the new worker_thread method of handling connections
@@ -352,10 +353,14 @@ void CtdlThreadStopAll(void)
 {
        /* First run any registered shutdown hooks.  This probably doesn't belong here. */
        PerformSessionHooks(EVT_SHUTDOWN);
-
+       
+       /* then close all tcp ports so nobody else can talk to us anymore. */
+       CtdlShutdownServiceHooks();
        //FIXME: The signalling of the condition should not be in the critical_section
        // We need to build a list of threads we are going to signal and then signal them afterwards
        
+       ShutDownEventQueue();
+
        CtdlThreadNode *this_thread;
        
        begin_critical_section(S_THREAD_LIST);
@@ -618,7 +623,7 @@ static void ctdl_internal_thread_cleanup(void *arg)
                const char *name = CT->name;
                const pid_t tid = CT->tid;
 
-               CtdlLogPrintf(CTDL_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, tid);
+               CtdlLogPrintf(CTDL_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, (unsigned long) tid);
        }
        else 
        {
@@ -712,7 +717,10 @@ void CtdlThreadGC (void)
                
                if ((that_thread->state == CTDL_THREAD_STOP_REQ || that_thread->state == CTDL_THREAD_STOPPING)
                        && (!citthread_equal(that_thread->tid, citthread_self())))
-                               CtdlLogPrintf(CTDL_DEBUG, "Waiting for thread %s (0x%08lx) to exit.\n", that_thread->name, that_thread->tid);
+               {
+                       CtdlLogPrintf(CTDL_DEBUG, "Waiting for thread %s (0x%08lx) to exit.\n", that_thread->name, that_thread->tid);
+                       terminate_stuck_sessions();
+               }
                else
                {
                        /**
@@ -1249,7 +1257,7 @@ void go_threading(void)
        /*
         * This thread is now used for garbage collection of other threads in the thread list
         */
-       CtdlLogPrintf(CTDL_INFO, "Startup thread %d becoming garbage collector,\n", citthread_self());
+       CtdlLogPrintf(CTDL_INFO, "Startup thread %ld becoming garbage collector,\n", (long) citthread_self());
 
        /*
         * We do a lot of locking and unlocking of the thread list in here.