]> 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 c221d6aafbf6949fd9bfa939f283999bcdee13ff..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();
@@ -334,8 +360,14 @@ int is_public_client(void)
 
                fp = fopen(public_clients_file, "r");
                if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
-                       for (i=0; i<strlen(buf); ++i) {
-                               if (buf[i] == '#') buf[i] = 0;
+                       char *ptr;
+                       ptr = buf;
+                       while (!IsEmptyStr(ptr)) {
+                               if (*ptr == '#') {
+                                       *ptr = 0;
+                                       break;
+                               }
+                               else ptr++;
                        }
                        while (isspace((buf[strlen(buf)-1]))) {
                                buf[strlen(buf)-1] = 0;
@@ -534,7 +566,7 @@ void cmd_emsg(char *mname)
        if (CtdlAccessCheck(ac_aide)) return;
 
        extract_token(buf, mname, 0, '|', sizeof buf);
-       for (a=0; a<strlen(buf); ++a) {         /* security measure */
+       for (a=0; !IsEmptyStr(&buf[a]); ++a) {          /* security measure */
                if (buf[a] == '/') buf[a] = '.';
        }