]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
destroy_network_queue_room() is now called via the cleanup hook mechanism.
[citadel.git] / citadel / citserver.c
index 6d19990140b1fe906e4ce696e4b25177ccb41ae2..87f4f6f827d4c65be909a214d6e092a56f77152d 100644 (file)
 # endif
 #endif
 
+#if HAVE_BACKTRACE
+#include <execinfo.h>
+#endif
+
 #include <ctype.h>
 #include <string.h>
 #include <dirent.h>
@@ -53,7 +57,7 @@
 #include "control.h"
 #include "tools.h"
 #include "euidindex.h"
-#include "serv_network.h"      /* Needed for destroy_network_queue_room called from master_cleanup */
+/*#include "serv_network.h"*/  /* Needed for destroy_network_queue_room called from master_cleanup */
 
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
@@ -66,6 +70,28 @@ int ScheduledShutdown = 0;
 int do_defrag = 0;
 time_t server_startup_time;
 
+/**
+ * \brief print the actual stack frame.
+ */
+void cit_backtrace(void)
+{
+#ifdef HAVE_BACKTRACE
+       void *stack_frames[50];
+       size_t size, i;
+       char **strings;
+
+
+       size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
+       strings = backtrace_symbols(stack_frames, size);
+       for (i = 0; i < size; i++) {
+               if (strings != NULL)
+                       lprintf(1, "%s\n", strings[i]);
+               else
+                       lprintf(1, "%p\n", stack_frames[i]);
+       }
+       free(strings);
+#endif
+}
 /*
  * Various things that need to be initialized at startup
  */
@@ -150,7 +176,7 @@ void master_cleanup(int exitcode) {
        close_databases();
 
        /* flush the networker stuff */
-       destroy_network_queue_room();
+/*     destroy_network_queue_room();*/
 
        /* Do system-dependent stuff */
        sysdep_master_cleanup();
@@ -337,7 +363,10 @@ int is_public_client(void)
                        char *ptr;
                        ptr = buf;
                        while (!IsEmptyStr(ptr)) {
-                               if (buf[i] == '#') buf[i] = 0;
+                               if (*ptr == '#') {
+                                       *ptr = 0;
+                                       break;
+                               }
                                else ptr++;
                        }
                        while (isspace((buf[strlen(buf)-1]))) {