dovecot-1.1: master: Don't print "last died with error .." for f...

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 25 16:07:35 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/2a7368d692ae
changeset: 7966:2a7368d692ae
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 25 15:17:46 2008 +0300
description:
master: Don't print "last died with error .." for fatals that were from forked child processes.

diffstat:

1 file changed, 14 insertions(+), 8 deletions(-)
src/master/main.c |   22 ++++++++++++++--------

diffs (46 lines):

diff -r 48840b2d4b18 -r 2a7368d692ae src/master/main.c
--- a/src/master/main.c	Fri Oct 24 01:56:13 2008 +0300
+++ b/src/master/main.c	Sat Oct 25 15:17:46 2008 +0300
@@ -35,6 +35,7 @@
 #define FATAL_FILENAME "master-fatal.lastlog"
 
 static const char *configfile = SYSCONFDIR "/" PACKAGE ".conf";
+static pid_t master_original_pid;
 
 struct ioloop *ioloop;
 int null_fd = -1, inetd_login_fd;
@@ -56,14 +57,18 @@ master_fatal_callback(enum log_type type
 	va_list args2;
 	int fd;
 
-	/* write the error message to a file */
-	path = t_strconcat(set->base_dir, "/"FATAL_FILENAME, NULL);
-	fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
-	if (fd != -1) {
-		VA_COPY(args2, args);
-		str = t_strdup_vprintf(format, args2);
-		write_full(fd, str, strlen(str));
-		(void)close(fd);
+	/* if we already forked a child process, this isn't fatal for the
+	   main process and there's no need to write the fatal file. */
+	if (getpid() == master_original_pid) {
+		/* write the error message to a file */
+		path = t_strconcat(set->base_dir, "/"FATAL_FILENAME, NULL);
+		fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
+		if (fd != -1) {
+			VA_COPY(args2, args);
+			str = t_strdup_vprintf(format, args2);
+			write_full(fd, str, strlen(str));
+			(void)close(fd);
+		}
 	}
 
 	/* write it to log as well */
@@ -566,6 +571,7 @@ int main(int argc, char *argv[])
 	auth_warning_print(settings_root);
 	if (!foreground)
 		daemonize(settings_root->defaults);
+	master_original_pid = getpid();
 
 	ioloop = io_loop_create();
 


More information about the dovecot-cvs mailing list