EVENT-Backtrace enableable on its own by now.
[citadel.git] / citadel / event_client.c
index d0e0fd9aefe9f20295a8827fda8fb5dabcf3f26b..697fd7bcd87a0e171e54fd24090a11b82e2a9a5d 100644 (file)
@@ -976,6 +976,7 @@ int InitcURLIOStruct(AsyncIO *IO,
 
 }
 
+extern int DebugEventLoopBacktrace;
 void EV_backtrace(AsyncIO *IO)
 {
 #ifdef HAVE_BACKTRACE
@@ -983,14 +984,17 @@ void EV_backtrace(AsyncIO *IO)
        size_t size, i;
        char **strings;
 
-
+       if ((IO == NULL) || (DebugEventLoopBacktrace == 0))
+               return;
        size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
-               if (strings != NULL)
+               if (strings != NULL) {
                        EV_syslog(LOG_ALERT, " BT %s\n", strings[i]);
-               else
+               }
+               else {
                        EV_syslog(LOG_ALERT, " BT %p\n", stack_frames[i]);
+               }
        }
        free(strings);
 #endif