]> code.citadel.org Git - citadel.git/blobdiff - citadel/server_main.c
threads are using signals and the GC code is #ifdef if available.
[citadel.git] / citadel / server_main.c
index 0503221dae6fdf5619361878d04fbcc197e1fb36..62a06ccd118f0941f4a7235148310de6af69b998 100644 (file)
@@ -55,7 +55,9 @@
 #include "user_ops.h"
 #include "housekeeping.h"
 #include "svn_revision.h"
-#include "citadel_dirs.c"
+#include "citadel_dirs.h"
+
+#include "context.h"
 
 #include "modules_init.h"
 #include "ecrash.h"
@@ -71,8 +73,6 @@ const char *CitadelServiceUDS="citadel-UDS";
 const char *CitadelServiceTCP="citadel-TCP";
 
 
-extern struct CitContext masterCC;
-
 
 void go_threading(void);
 
@@ -99,6 +99,13 @@ int main(int argc, char **argv)
        eCrashParameters params;
 //     eCrashSymbolTable symbol_table;
 #endif
+
+#ifdef HAVE_GC
+       GC_INIT();
+       GC_find_leak = 1;
+#endif
+
+
        /* initialise semaphores here. Patch by Matt and davew
         * its called here as they are needed by CtdlLogPrintf for thread safety
         */
@@ -121,6 +128,11 @@ int main(int argc, char **argv)
                        running_as_daemon = 1;
                }
 
+               /* run a few stats if -s was specified */
+               else if (!strncmp(argv[a], "-s", 2)) {
+                       statcount = atoi(&argv[a][2]);
+               }
+
                /* -x specifies the desired logging level */
                else if (!strncmp(argv[a], "-x", 2)) {
                        verbosity = atoi(&argv[a][2]);
@@ -133,7 +145,6 @@ int main(int argc, char **argv)
                        else
                                safestrncpy(relhome, &argv[a][2],
                                                        sizeof relhome);
-                       home_specified = 1;
                        home=1;
                }
 
@@ -156,7 +167,7 @@ int main(int argc, char **argv)
                        CtdlLogPrintf(CTDL_EMERG,       "citserver: usage: "
                                        "citserver "
                                        "[-lLogFacility] "
-                                       "[-d] [-D] "
+                                       "[-d] [-D] [-s]"
                                        " [-tTraceFile]"
                                        " [-xLogLevel] [-hHomeDir]\n");
                        exit(1);
@@ -263,12 +274,12 @@ int main(int argc, char **argv)
 /**
  * Load the user for the masterCC or create them if they don't exist
  */
-       if (getuser(&masterCC.user, "SYS_Citadel"))
+       if (CtdlGetUser(&masterCC.user, "SYS_Citadel"))
        {
                /** User doesn't exist. We can't use create user here as the user number needs to be 0 */
                strcpy (masterCC.user.fullname, "SYS_Citadel") ;
-               putuser(&masterCC.user);
-               getuser(&masterCC.user, "SYS_Citadel"); /** Just to be safe */
+               CtdlPutUser(&masterCC.user);
+               CtdlGetUser(&masterCC.user, "SYS_Citadel"); /** Just to be safe */
        }
        
        /*
@@ -311,6 +322,14 @@ int main(int argc, char **argv)
                start_chkpwd_daemon();
        }
 
+
+       /*
+        * check, whether we're fired up another time after a crash.
+        * if, post an aide message, so the admin has a chance to react.
+        */
+       checkcrash ();
+
+
        /*
         * Now that we've bound the sockets, change to the Citadel user id and its
         * corresponding group ids