From 591b04f1fcb1d91c8da29a1bee0b3182da96f9f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Wed, 29 Aug 2007 17:52:08 +0000 Subject: [PATCH] * make backtrace optional. --- citadel/citadel.c | 6 ++++-- citadel/citserver.c | 1 + citadel/commands.c | 5 ++++- citadel/configure.ac | 13 ++++++++++++- citadel/ecrash.c | 3 ++- citadel/server_main.c | 5 ++++- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/citadel/citadel.c b/citadel/citadel.c index 4330cf784..d5c0b1059 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -1405,12 +1405,14 @@ int main(int argc, char **argv) char relhome[PATH_MAX]=""; char ctdldir[PATH_MAX]=CTDLDIR; int lp; +#ifdef HAVE_BACKTRACE eCrashParameters params; // eCrashSymbolTable symbol_table; - +#endif calc_dirs_n_files(relh, home, relhome, ctdldir); +#ifdef HAVE_BACKTRACE bzero(¶ms, sizeof(params)); params.filename = file_pid_paniclog; // panic_fd=open(file_pid_paniclog, O_APPEND|O_CREAT|O_DIRECT); @@ -1426,7 +1428,7 @@ int main(int argc, char **argv) params.signals[3]=SIGABRT; eCrash_Init(¶ms); - +#endif setIPCDeathHook(screen_delete); setIPCErrorPrintf(err_printf); setCryptoStatusHook(statusHook); diff --git a/citadel/citserver.c b/citadel/citserver.c index a25a2ea20..79ebddefa 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -76,6 +76,7 @@ int panic_fd; void cit_backtrace(void) { #ifdef HAVE_BACKTRACE +snatoehu void *stack_frames[50]; size_t size, i; char **strings; diff --git a/citadel/commands.c b/citadel/commands.c index fb1b99b9b..9e2af9991 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -394,6 +394,7 @@ static int async_ka_enabled = 0; static void *ka_thread(void *arg) { +#ifdef HAVE_BACKTRACE char threadName[256]; // Set up our name @@ -401,12 +402,14 @@ static void *ka_thread(void *arg) // Register for tracing eCrash_RegisterThread(threadName, 0); - +#endif really_do_keepalive(); pthread_detach(ka_thr_handle); ka_thr_active = 0; +#ifdef HAVE_BACKTRACE eCrash_UnregisterThread(); +#endif return NULL; } diff --git a/citadel/configure.ac b/citadel/configure.ac index af09ef2d9..79ce0e2dd 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -294,7 +294,18 @@ dnl Checks for libraries. dnl We want to test for the following in libc before checking for their dnl respective libraries, because some systems (like Irix) have both, and the dnl non-libc versions may be broken. -AC_CHECK_FUNCS(crypt gethostbyname connect backtrace) +AC_CHECK_FUNCS(crypt gethostbyname connect ) + + +dnl disable backtrace if we don't want it. +AC_ARG_WITH(backtrace, + [ --with-backtrace Disable backtrace dumps in the syslog], + [ if test "x$withval" != "xno" ; then + AC_CHECK_FUNCS(backtrace) + fi + ] +) + if test "$ac_cv_func_gethostbyname" = no; then AC_CHECK_LIB(nsl, gethostbyname) diff --git a/citadel/ecrash.c b/citadel/ecrash.c index 2c04fe97e..f67e67762 100644 --- a/citadel/ecrash.c +++ b/citadel/ecrash.c @@ -27,7 +27,7 @@ #include "ecrash.h" #define NIY() printf("%s: Not Implemented Yet!\n", __FUNCTION__) - +#ifdef HAVE_BACKTRACE static eCrashParameters gbl_params; static int gbl_fd=-1; @@ -644,3 +644,4 @@ int eCrash_UnregisterThread( void ) return removeThreadFromList(pthread_self()); } /* eCrash_UnregisterThread */ +#endif diff --git a/citadel/server_main.c b/citadel/server_main.c index bd3c00321..a2bc2b4ef 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -89,9 +89,10 @@ int main(int argc, char **argv) #ifdef HAVE_RUN_DIR struct stat filestats; #endif +#ifdef HAVE_BACKTRACE eCrashParameters params; // eCrashSymbolTable symbol_table; - +#endif /* initialise semaphores here. Patch by Matt and davew * its called here as they are needed by lprintf for thread safety */ @@ -164,6 +165,7 @@ int main(int argc, char **argv) drop_root_perms = 1; } +#ifdef HAVE_BACKTRACE bzero(¶ms, sizeof(params)); params.filename = file_pid_paniclog; panic_fd=open(file_pid_paniclog, O_APPEND|O_CREAT|O_DIRECT); @@ -183,6 +185,7 @@ int main(int argc, char **argv) eCrash_RegisterThread("MasterThread", 0); /// signal(SIGSEGV, cit_panic_backtrace); +#endif /* Initialize the syslogger. Yes, we are really using 0 as the * facility, because we are going to bitwise-OR the facility to * the severity of each message, allowing us to write to other -- 2.30.2