]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
Changed the way we do the TSD area.
[citadel.git] / citadel / citserver.c
index 6eb838c4537b60f84925bea4a7c50d13e36ba2a9..d04ee38b231f2626536496f4daaa8c64f5708d86 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "sysdep_decls.h"
 #include "file_ops.h"
 #include "policy.h"
 #include "control.h"
-#include "tools.h"
 #include "euidindex.h"
 
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
 #endif
 
+#include "ctdl_module.h"
+
+
 struct CitContext *ContextList = NULL;
 struct CitContext* next_session = NULL;
 char *unique_session_numbers;
@@ -132,6 +135,10 @@ void master_startup(void) {
        lprintf(CTDL_INFO, "Opening databases\n");
        open_databases();
 
+       ctdl_thread_internal_init_tsd();
+       
+       CtdlThreadAllocTSD();
+       
        if (do_defrag) {
                defrag_databases();
        }
@@ -176,7 +183,6 @@ void master_startup(void) {
  */
 void master_cleanup(int exitcode) {
        struct CleanupFunctionHook *fcn;
-       struct MaintenanceThreadHook *m_fcn;
        static int already_cleaning_up = 0;
 
        if (already_cleaning_up) while(1) sleep(1);
@@ -190,12 +196,6 @@ void master_cleanup(int exitcode) {
        /* Close the AdjRefCount queue file */
        AdjRefCount(-1, 0);
 
-       for (m_fcn = MaintenanceThreadHookTable; m_fcn != NULL; m_fcn = m_fcn->next) {
-               lprintf(CTDL_INFO, "Waiting for maintenance thread \"%s\" to shut down\n", m_fcn->name);
-               pthread_join(m_fcn->MaintenanceThread_tid, NULL);
-       }
-       
-
        /* Close databases */
        lprintf(CTDL_INFO, "Closing databases\n");
        close_databases();
@@ -300,7 +300,11 @@ void cmd_info(void) {
        }
 
        cprintf("%s\n", config.c_default_cal_zone);
-
+       /* Output load averages */
+       cprintf("%f\n", CtdlThreadLoadAvg);
+       cprintf("%f\n", CtdlThreadWorkerAvg);
+       cprintf("%d\n", CtdlThreadGetCount());
+       
        cprintf("000\n");
 }
 
@@ -824,9 +828,9 @@ void cmd_down(char *argbuf) {
        }
        else
        {
-               cprintf(Reply, CIT_OK);
+               cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN);
        }
-       time_to_die = 1;
+       CtdlThreadStopAll();
 }
 
 /*
@@ -837,7 +841,7 @@ void cmd_halt(void) {
        if (CtdlAccessCheck(ac_aide)) return;
 
        cprintf("%d Halting server.  Goodbye.\n", CIT_OK);
-       time_to_die = 1;
+       CtdlThreadStopAll();
        shutdown_and_halt = 1;
 }