dovecot: If child process logged a fatal failure, don't show "re...

dovecot at dovecot.org dovecot at dovecot.org
Tue Oct 9 17:23:18 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/402d14b5ef8b
changeset: 6542:402d14b5ef8b
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 09 17:23:11 2007 +0300
description:
If child process logged a fatal failure, don't show "returned error 89"
message.

diffstat:

9 files changed, 29 insertions(+), 7 deletions(-)
src/master/auth-process.c  |    5 +++--
src/master/child-process.c |    5 ++++-
src/master/child-process.h |    2 ++
src/master/dict-process.c  |    1 +
src/master/log.c           |   17 ++++++++++++++---
src/master/log.h           |    1 +
src/master/login-process.c |    1 +
src/master/mail-process.c  |    1 +
src/master/ssl-init.c      |    3 ++-

diffs (184 lines):

diff -r 56d6a891c41c -r 402d14b5ef8b src/master/auth-process.c
--- a/src/master/auth-process.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/auth-process.c	Tue Oct 09 17:23:11 2007 +0300
@@ -59,9 +59,9 @@ bool have_initialized_auth_processes = F
 bool have_initialized_auth_processes = FALSE;
 
 static struct child_process auth_child_process =
-	{ PROCESS_TYPE_AUTH };
+	{ PROCESS_TYPE_AUTH, 0 };
 static struct child_process auth_worker_child_process =
-	{ PROCESS_TYPE_AUTH_WORKER };
+	{ PROCESS_TYPE_AUTH_WORKER, 0 };
 
 static struct timeout *to;
 static unsigned int auth_tag;
@@ -535,6 +535,7 @@ static int create_auth_process(struct au
 		/* master */
 		prefix = t_strdup_printf("auth(%s): ", group->set->name);
 		log_set_prefix(log, prefix);
+		log_set_pid(log, pid);
 
 		net_set_nonblock(fd[0], TRUE);
 		fd_close_on_exec(fd[0], TRUE);
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/child-process.c
--- a/src/master/child-process.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/child-process.c	Tue Oct 09 17:23:11 2007 +0300
@@ -99,7 +99,7 @@ static const char *get_exit_status_messa
 		return "exec() failed";
 
 	case FATAL_DEFAULT:
-		return NULL;
+		return "Fatal failure";
 	}
 
 	return NULL;
@@ -139,6 +139,9 @@ static void sigchld_handler(int signo AT
 			} else if (status == 1 &&
 				   process_type == PROCESS_TYPE_SSL_PARAM) {
 				/* kludgy. hide this failure. */
+			} else if (status == FATAL_DEFAULT &&
+				   process->seen_fatal) {
+				/* the error was already logged. */
 			} else {
 				msg = get_exit_status_message(status);
 				msg = msg == NULL ? "" :
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/child-process.h
--- a/src/master/child-process.h	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/child-process.h	Tue Oct 09 17:23:11 2007 +0300
@@ -16,6 +16,8 @@ enum process_type {
 
 struct child_process {
 	enum process_type type;
+
+	unsigned int seen_fatal:1;
 };
 
 typedef void child_process_destroy_callback_t(struct child_process *process,
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/dict-process.c
--- a/src/master/dict-process.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/dict-process.c	Tue Oct 09 17:23:11 2007 +0300
@@ -55,6 +55,7 @@ static int dict_process_start(struct dic
 		/* master */
 		child_process_add(pid, &process->process);
 		log_set_prefix(log, "dict: ");
+		log_set_pid(log, pid);
 		(void)close(log_fd);
 
 		process->log = log;
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/log.c
--- a/src/master/log.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/log.c	Tue Oct 09 17:23:11 2007 +0300
@@ -5,6 +5,7 @@
 #include "istream.h"
 #include "fd-set-nonblock.h"
 #include "fd-close-on-exec.h"
+#include "child-process.h"
 #include "log.h"
 
 #include <unistd.h>
@@ -15,6 +16,7 @@ struct log_io {
 
 	struct io *io;
 	struct istream *stream;
+	pid_t pid;
 
 	time_t log_stamp;
 	unsigned int log_counter;
@@ -89,6 +91,7 @@ static void log_unthrottle(struct log_io
 
 static int log_it(struct log_io *log_io, const char *line, bool continues)
 {
+	struct child_process *process;
 	const char *prefix;
 	enum log_type log_type;
 
@@ -116,10 +119,12 @@ static int log_it(struct log_io *log_io,
 		log_type = LOG_TYPE_ERROR;
 		break;
 	case 'F':
-		log_type = LOG_TYPE_FATAL;
-		break;
 	case 'P':
-		log_type = LOG_TYPE_PANIC;
+		log_type = log_io->next_log_type == 'F' ?
+			LOG_TYPE_FATAL : LOG_TYPE_PANIC;
+		process = child_process_lookup(log_io->pid);
+		if (process != NULL)
+			process->seen_fatal = TRUE;
 		break;
 	default:
 		log_type = LOG_TYPE_ERROR;
@@ -190,6 +195,7 @@ int log_create_pipe(struct log_io **log_
 
 	log_io = i_new(struct log_io, 1);
 	log_io->refcount = 1;
+	log_io->pid = (pid_t)-1;
 	log_io->stream = i_stream_create_fd(fd[0], 1024, TRUE);
 	log_io->max_lines_per_sec =
 		max_lines_per_sec != 0 ? max_lines_per_sec : (unsigned int)-1;
@@ -211,6 +217,11 @@ void log_set_prefix(struct log_io *log, 
 {
 	i_free(log->prefix);
 	log->prefix = i_strdup(prefix);
+}
+
+void log_set_pid(struct log_io *log, pid_t pid)
+{
+	log->pid = pid;
 }
 
 void log_ref(struct log_io *log_io)
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/log.h
--- a/src/master/log.h	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/log.h	Tue Oct 09 17:23:11 2007 +0300
@@ -5,6 +5,7 @@ struct log_io;
 
 int log_create_pipe(struct log_io **log_r, unsigned int max_lines_per_sec);
 void log_set_prefix(struct log_io *log, const char *prefix);
+void log_set_pid(struct log_io *log, pid_t pid);
 
 void log_ref(struct log_io *log_io);
 void log_unref(struct log_io *log_io);
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/login-process.c
--- a/src/master/login-process.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/login-process.c	Tue Oct 09 17:23:11 2007 +0300
@@ -627,6 +627,7 @@ static pid_t create_login_process(struct
 		prefix = t_strdup_printf("%s-login: ",
 				process_names[group->mail_process_type]);
 		log_set_prefix(log, prefix);
+		log_set_pid(log, pid);
 
 		net_set_nonblock(fd[0], TRUE);
 		fd_close_on_exec(fd[0], TRUE);
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/mail-process.c
--- a/src/master/mail-process.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/mail-process.c	Tue Oct 09 17:23:11 2007 +0300
@@ -672,6 +672,7 @@ create_mail_process(enum process_type pr
 
 		if (!dump_capability) {
 			log_set_prefix(log, str_c(str));
+			log_set_pid(log, pid);
 			if (process_group == NULL) {
 				process_group =
 					mail_process_group_create(process_type,
diff -r 56d6a891c41c -r 402d14b5ef8b src/master/ssl-init.c
--- a/src/master/ssl-init.c	Tue Oct 09 17:11:44 2007 +0300
+++ b/src/master/ssl-init.c	Tue Oct 09 17:23:11 2007 +0300
@@ -18,7 +18,7 @@
 #include <sys/stat.h>
 
 static struct child_process ssl_param_child_process =
-	{ PROCESS_TYPE_SSL_PARAM };
+	{ PROCESS_TYPE_SSL_PARAM, 0 };
 
 static struct timeout *to;
 static char *generating_path = NULL;
@@ -50,6 +50,7 @@ static void start_generate_process(const
 		/* parent */
 		i_assert(generating_path == NULL);
 		generating_path = i_strdup(fname);
+		log_set_pid(log, pid);
 		child_process_add(pid, &ssl_param_child_process);
 		(void)close(log_fd);
 		return;


More information about the dovecot-cvs mailing list