X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fthreads.c;h=9782d05fc005c5bf9a3f0567cb1c32dd5db65e90;hb=1421d26887f154439d2cd27075c7e85dc22f644f;hp=4f9d1428cf9c9fa84f2690ad829793c9b949bc65;hpb=e0288cfdf0bfeed17641a79257c0e92c32630483;p=citadel.git diff --git a/citadel/threads.c b/citadel/threads.c index 4f9d1428c..9782d05fc 100644 --- a/citadel/threads.c +++ b/citadel/threads.c @@ -38,6 +38,7 @@ #include "config.h" #include "citserver.h" #include "sysdep_decls.h" +#include "context.h" /* * define this to use the new worker_thread method of handling connections @@ -1196,14 +1197,7 @@ int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds * or timeout so this thread could stop if asked to do so. * Anything else means it needs to continue unless the system is shutting down */ - if (ret <= 0) - { - /** - * select says nothing to do so we can change to running if we haven't been asked to stop. - */ - ctdl_thread_internal_change_state(CT, CTDL_THREAD_RUNNING); - } - else + if (ret > 0) { /** * The select says this thread needs to do something useful. @@ -1227,6 +1221,8 @@ int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds citthread_mutex_unlock(&CT->ThreadMutex); } + ctdl_thread_internal_change_state(CT, CTDL_THREAD_RUNNING); + return ret; } @@ -1347,7 +1343,7 @@ void go_threading(void) } CtdlThreadGC(); - + if (CtdlThreadGetCount() <= 1) // Shutting down clean up the garbage collector { CtdlThreadGC(); @@ -1574,7 +1570,6 @@ int execute_session(struct CitContext *bind_me) -extern void dead_session_purge(int force); /* * A new worker_thread loop.