]> code.citadel.org Git - citadel.git/blobdiff - citadel/threads.c
foo
[citadel.git] / citadel / threads.c
index 2f5f8d68222e6f00aa890b22fc4f3165f2c01234..4da15e6fb650a4985fa5b4161df92e17706f535a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Thread handling stuff for Citadel server
  *
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -19,6 +19,7 @@
 #include "modules_init.h"
 #include "serv_extensions.h"
 #include "ctdl_module.h"
+#include "config.h"
 #include "context.h"
 #include "threads.h"
 
@@ -119,7 +120,7 @@ void *CTC_backend(void *supplied_start_routine)
 
        start_routine(NULL);
 
-       free(mytsd);
+//     free(mytsd);
        return(NULL);
 }
 
@@ -137,7 +138,7 @@ void CtdlThreadCreate(void *(*start_routine)(void*))
        ret = pthread_attr_init(&attr);
        ret = pthread_attr_setstacksize(&attr, THREADSTACKSIZE);
        ret = pthread_create(&thread, &attr, CTC_backend, (void *)start_routine);
-       if (ret != 0) syslog(LOG_EMERG, "pthread_create() : %s", strerror(errno));
+       if (ret != 0) syslog(LOG_ERR, "pthread_create() : %m");
 }
 
 
@@ -145,17 +146,14 @@ void InitializeMasterTSD(void) {
        memset(&masterTSD, 0, sizeof(struct thread_tsd));
 }
 
-extern void ShutDownEventQueues(void);
 
-int EventQShuttingDown = 0;
-int EVQShutDown = 0;
 /*
  * Initialize the thread system
  */
 void go_threading(void)
 {
        if (pthread_key_create(&ThreadKey, NULL) != 0) {
-               syslog(LOG_EMERG, "pthread_key_create() : %s", strerror(errno));
+               syslog(LOG_ERR, "pthread_key_create() : %m");
                abort();
        }
 
@@ -171,22 +169,13 @@ void go_threading(void)
         * they are all in use.
         */
        while (!server_shutting_down) {
-               if ((active_workers == num_workers) && (num_workers < config.c_max_workers)) {
+               if ((active_workers == num_workers) && (num_workers < CtdlGetConfigInt("c_max_workers"))) {
                        CtdlThreadCreate(worker_thread);
                }
                usleep(1000000);
        }
 
        /* When we get to this point we are getting ready to shut down our Citadel server */
-       if (!EventQShuttingDown)
-       {
-               EventQShuttingDown = 1;
-               ShutDownEventQueues();
-       }
-       while (!EVQShutDown)
-               usleep(1000000);
-
-
        terminate_all_sessions();               /* close all client sockets */
        CtdlShutdownServiceHooks();             /* close all listener sockets to prevent new connections */
        PerformSessionHooks(EVT_SHUTDOWN);      /* run any registered shutdown hooks */