diff --git a/configure.in b/configure.in index 1447200..a3b19cf 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ AC_ARG_ENABLE(debug, [ enable_debug=$enableval ], [ enable_debug=no ]) -AM_CONDITIONAL(DEBUG, test x$enable_debug = xtrue) +AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes) case $enable_debug in yes) @@ -24,11 +24,20 @@ no) AC_MSG_ERROR(bad value ${enable_debug} for --enable-debug) esac +backtrace= +if test x$enable_debug = xyes ; then + AC_CHECK_FUNC(backtrace_symbols_fd, [ + AC_DEFINE(HAVE_BACKTRACE, [], [Use Glibcs backtrace function on fatal()]) + LDFLAGS="-rdynamic $LDFLAGS" + backtrace="(with backtrace)" + ]) +fi + AC_ARG_ENABLE(oidentd, [ --enable-oidentd Enable oidentd support (bip overwrites ~/.oidentd.conf with this on!)], -enable_oidentd=yes -AC_DEFINE([HAVE_OIDENTD], [], [Enable oidentd.conf management support]), -[enable_oidentd=no] + enable_oidentd=yes + AC_DEFINE([HAVE_OIDENTD], [], [Enable oidentd.conf management support]), + [enable_oidentd=no] ) AM_CONDITIONAL(OIDENTD, test x$enable_identd = xyes) @@ -39,16 +48,15 @@ AC_ARG_ENABLE(openssl, [ enable_openssl=yes ]) if test "x$enable_openssl" = "xyes" ; then - AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], - [AC_MSG_ERROR([library 'crypto' is required for OpenSSL support])]) - - AC_CHECK_LIB(ssl, SSL_read, [], - [AC_MSG_ERROR( - [library 'ssl' is required for OpenSSL support])], - -lcrypto) + AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [ + AC_MSG_ERROR([library 'crypto' is required for OpenSSL support]) + ], -lcrypto) + AC_CHECK_LIB(ssl, SSL_read, [], [ + AC_MSG_ERROR([library 'ssl' is required for OpenSSL support]) + ]) fi AC_OUTPUT(Makefile src/Makefile samples/Makefile) echo OPENSSL: $enable_openssl -echo DEBUG: $enable_debug +echo DEBUG: $enable_debug $backtrace echo OIDENTD: $enable_oidentd diff --git a/src/config.h.in b/src/config.h.in index c27f0ea..875c464 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,5 +1,8 @@ /* src/config.h.in. Generated from configure.in by autoheader. */ +/* Use Glibcs backtrace function on fatal() */ +#undef HAVE_BACKTRACE + /* Define to 1 if you have the `crypto' library (-lcrypto). */ #undef HAVE_LIBCRYPTO diff --git a/src/irc.c b/src/irc.c index 800bd87..9b45fae 100644 --- a/src/irc.c +++ b/src/irc.c @@ -1631,7 +1631,7 @@ static int irc_mode(struct link_server *server, struct line *line) if (!hash_includes(&channel->ovmasks, nick)) return ERR_PROTOCOL; - ovmask = (long int)hash_get(&channel->ovmasks, nick); + ovmask = (long int)hash_remove(&channel->ovmasks, nick); if (add) ovmask |= NICKHALFOP; else @@ -1647,7 +1647,7 @@ static int irc_mode(struct link_server *server, struct line *line) if (!hash_includes(&channel->ovmasks, nick)) return ERR_PROTOCOL; - ovmask = (long int)hash_get(&channel->ovmasks, nick); + ovmask = (long int)hash_remove(&channel->ovmasks, nick); if (add) ovmask |= NICKVOICED; else diff --git a/src/util.c b/src/util.c index d7d5eec..e274102 100644 --- a/src/util.c +++ b/src/util.c @@ -198,15 +198,34 @@ void mylog(int level, char *fmt, ...) va_end(ap); } +#ifdef HAVE_BACKTRACE +#include + +void print_trace(void) +{ + void *array[32]; + size_t size; + size_t i; + + size = backtrace(array, 32); + fflush(conf_global_log_file); + backtrace_symbols_fd(array, size, fileno(conf_global_log_file)); +} +#endif + extern char *conf_pid_file; void fatal(char *fmt, ...) { va_list ap; + va_start(ap, fmt); - _mylog(LOG_FATAL, fmt, ap); - va_end(ap); + +#ifdef HAVE_BACKTRACE + print_trace(); +#endif + exit(200); }