Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6542:402d14b5ef8b HEAD
If child process logged a fatal failure, don't show "returned error 89"
message.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 09 Oct 2007 17:23:11 +0300 |
parents | 56d6a891c41c |
children | 2d0b59aeb41a |
files | src/master/auth-process.c src/master/child-process.c src/master/child-process.h src/master/dict-process.c src/master/log.c src/master/log.h src/master/login-process.c src/master/mail-process.c src/master/ssl-init.c |
diffstat | 9 files changed, 29 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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 = 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 @@ /* 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);
--- 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 @@ return "exec() failed"; case FATAL_DEFAULT: - return NULL; + return "Fatal failure"; } return NULL; @@ -139,6 +139,9 @@ } 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 ? "" :
--- 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 @@ struct child_process { enum process_type type; + + unsigned int seen_fatal:1; }; typedef void child_process_destroy_callback_t(struct child_process *process,
--- 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 @@ /* master */ child_process_add(pid, &process->process); log_set_prefix(log, "dict: "); + log_set_pid(log, pid); (void)close(log_fd); process->log = log;
--- 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 io *io; struct istream *stream; + pid_t pid; time_t log_stamp; unsigned int log_counter; @@ -89,6 +91,7 @@ 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 @@ 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 @@ 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; @@ -213,6 +219,11 @@ 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) { log_io->refcount++;
--- 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 @@ 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);
--- 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 @@ 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);
--- 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 @@ 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,
--- 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 @@ /* 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;