dovecot-1.1: Print raw backtrace when dying with out-of-memory (...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 28 19:03:46 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/4c702defc245
changeset: 7562:4c702defc245
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 28 19:03:42 2008 +0300
description:
Print raw backtrace when dying with out-of-memory (with all log backends).

diffstat:

1 file changed, 14 insertions(+), 23 deletions(-)
src/lib/failures.c |   37 ++++++++++++++-----------------------

diffs (78 lines):

diff -r 1a58b18652a6 -r 4c702defc245 src/lib/failures.c
--- a/src/lib/failures.c	Tue May 27 02:09:47 2008 +0300
+++ b/src/lib/failures.c	Wed May 28 19:03:42 2008 +0300
@@ -138,14 +138,10 @@ default_handler(const char *prefix, int 
 	return ret;
 }
 
-void default_fatal_handler(enum log_type type, int status,
-			   const char *format, va_list args)
+static void ATTR_NORETURN
+default_fatal_finish(enum log_type type, int status)
 {
 	const char *backtrace;
-
-	if (default_handler(failure_log_type_prefixes[type], log_fd, format,
-			    args) < 0 && status == FATAL_DEFAULT)
-		status = FATAL_LOGWRITE;
 
 	if (type == LOG_TYPE_PANIC || status == FATAL_OUTOFMEM) {
 		if (backtrace_get(&backtrace) == 0)
@@ -156,6 +152,16 @@ void default_fatal_handler(enum log_type
 		abort();
 	else
 		failure_exit(status);
+}
+
+void default_fatal_handler(enum log_type type, int status,
+			   const char *format, va_list args)
+{
+	if (default_handler(failure_log_type_prefixes[type], log_fd, format,
+			    args) < 0 && status == FATAL_DEFAULT)
+		status = FATAL_LOGWRITE;
+
+	default_fatal_finish(type, status);
 }
 
 void default_error_handler(enum log_type type, const char *format, va_list args)
@@ -292,18 +298,11 @@ void i_syslog_fatal_handler(enum log_typ
 void i_syslog_fatal_handler(enum log_type type, int status,
 			    const char *fmt, va_list args)
 {
-	const char *backtrace;
 	if (syslog_handler(LOG_CRIT, type, fmt, args) < 0 &&
 	    status == FATAL_DEFAULT)
 		status = FATAL_LOGERROR;
 
-	if (type == LOG_TYPE_PANIC) {
-		if (backtrace_get(&backtrace) == 0)
-			i_error("Raw backtrace: %s", backtrace);
-		abort();
-	} else {
-		failure_exit(status);
-	}
+	default_fatal_finish(type, status);
 }
 
 void i_syslog_error_handler(enum log_type type, const char *fmt, va_list args)
@@ -412,19 +411,11 @@ i_internal_fatal_handler(enum log_type t
 i_internal_fatal_handler(enum log_type type, int status,
 			 const char *fmt, va_list args)
 {
-	const char *backtrace;
-
 	if (internal_handler(log_type_internal_chars[type], fmt, args) < 0 &&
 	    status == FATAL_DEFAULT)
 		status = FATAL_LOGERROR;
 
-	if (type == LOG_TYPE_PANIC) {
-		if (backtrace_get(&backtrace) == 0)
-			i_error("Raw backtrace: %s", backtrace);
-		abort();
-	} else {
-		failure_exit(status);
-	}
+	default_fatal_finish(type, status);
 }
 
 static void ATTR_FORMAT(2, 0)


More information about the dovecot-cvs mailing list