If this really started happening only with v1.2.4 -> v1.2.5, the only
change that looks anything like it could have to do with this problem is
the attached patch. I guess you could try reversing it and seeing if it
helps..

--- /home/timo/m/dovecot-1.2.4/src/master/main.c	2009-05-20 17:48:16.000000000 -0400
+++ ./main.c	2009-10-29 16:05:50.000000000 -0400
@@ -139,6 +139,46 @@
 	i_set_failure_timestamp_format(set->log_timestamp);
 }
 
+static void ATTR_NORETURN
+tee_fatal_handler(enum log_type type, int status, const char *fmt, va_list args)
+{
+	const struct settings *set = settings_root->defaults;
+	va_list args2;
+
+	VA_COPY(args2, args);
+	fprintf(stderr, "Fatal: %s\n", t_strdup_vprintf(fmt, args2));
+
+	if (*set->log_path == '\0') {
+		i_syslog_fatal_handler(type, status, fmt, args);
+	} else {
+		default_fatal_handler(type, status, fmt, args);
+	}
+}
+
+static void
+tee_error_handler(enum log_type type, const char *fmt, va_list args)
+{
+	const struct settings *set = settings_root->defaults;
+	va_list args2;
+
+	VA_COPY(args2, args);
+	fprintf(stderr, "Error: %s\n", t_strdup_vprintf(fmt, args2));
+
+	if (*set->log_path == '\0') {
+		i_syslog_error_handler(type, fmt, args);
+	} else {
+		default_error_handler(type, fmt, args);
+	}
+}
+
+static void set_tee_logfile(struct settings *set)
+{
+	set_logfile(set);
+
+	i_set_fatal_handler(tee_fatal_handler);
+	i_set_error_handler(tee_error_handler);
+}
+
 static void settings_reload(void)
 {
 	struct server_settings *old_set = settings_root;
@@ -222,7 +262,7 @@
 	fd_close_on_exec(null_fd, TRUE);
 }
 
-static void open_fds(void)
+static void open_std_fds(void)
 {
 	/* make sure all fds between 0..3 are used. */
 	while (null_fd < 4) {
@@ -232,12 +272,6 @@
 		fd_close_on_exec(null_fd, TRUE);
 	}
 
-	if (!IS_INETD()) {
-		T_BEGIN {
-			listeners_open_fds(NULL, FALSE);
-		} T_END;
-	}
-
 	/* close stdin and stdout. */
 	if (dup2(null_fd, 0) < 0)
 		i_fatal("dup2(0) failed: %m");
@@ -600,11 +634,20 @@
 		mail_process_exec(exec_protocol, exec_args);
 	}
 
-	if (!log_error)
-		open_fds();
+	/* closes stdin/stdout, must be after --exec-mail handling */
+	open_std_fds();
+
+	/* log all errors to both stderr and log file until we've finished
+	   startup. */
+	set_tee_logfile(settings_root->defaults);
 
 	fatal_log_check();
 	auth_warning_print(settings_root);
+
+	if (!log_error && !IS_INETD()) T_BEGIN {
+		listeners_open_fds(NULL, FALSE);
+	} T_END;
+
 	if (!foreground)
 		daemonize(settings_root->defaults);
 	master_original_pid = getpid();

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to