dovecot: If we see that Dovecot is already running, log the erro...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jan 16 18:41:06 EET 2008


details:   http://hg.dovecot.org/dovecot/rev/805d0831deb6
changeset: 7165:805d0831deb6
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jan 16 18:41:02 2008 +0200
description:
If we see that Dovecot is already running, log the error as fatal instead of
later giving "Invalid configuration" fatal.

diffstat:

1 file changed, 6 insertions(+), 11 deletions(-)
src/master/master-settings.c |   17 ++++++-----------

diffs (60 lines):

diff -r d349cdeddc7d -r 805d0831deb6 src/master/master-settings.c
--- a/src/master/master-settings.c	Wed Jan 16 18:24:09 2008 +0200
+++ b/src/master/master-settings.c	Wed Jan 16 18:41:02 2008 +0200
@@ -906,7 +906,7 @@ static bool settings_fix(struct settings
 	return nofixes ? TRUE : settings_do_fixes(set);
 }
 
-static int pid_file_is_running(const char *path)
+static void pid_file_check_running(const char *path)
 {
 	char buf[32];
 	int fd;
@@ -915,9 +915,8 @@ static int pid_file_is_running(const cha
 	fd = open(path, O_RDONLY);
 	if (fd == -1) {
 		if (errno == ENOENT)
-			return 0;
-		i_error("open(%s) failed: %m", path);
-		return -1;
+			return;
+		i_fatal("open(%s) failed: %m", path);
 	}
 
 	ret = read(fd, buf, sizeof(buf));
@@ -925,7 +924,7 @@ static int pid_file_is_running(const cha
 		if (ret == 0)
 			i_error("Empty PID file in %s, overriding", path);
 		else
-			i_error("read(%s) failed: %m", path);
+			i_fatal("read(%s) failed: %m", path);
 	} else {
 		pid_t pid;
 
@@ -935,15 +934,12 @@ static int pid_file_is_running(const cha
 		pid = atoi(buf);
 		if (pid == getpid() || (kill(pid, 0) < 0 && errno == ESRCH)) {
 			/* doesn't exist */
-			ret = 0;
 		} else {
-			i_error("Dovecot is already running with PID %s "
+			i_fatal("Dovecot is already running with PID %s "
 				"(read from %s)", buf, path);
-			ret = 1;
 		}
 	}
 	(void)close(fd);
-	return ret;
 }
 
 static struct auth_settings *
@@ -1458,8 +1454,7 @@ bool master_settings_read(const char *pa
 
 		path = t_strconcat(ctx.root->defaults->base_dir,
 				   "/master.pid", NULL);
-		if (pid_file_is_running(path) != 0)
-			return FALSE;
+		pid_file_check_running(path);
 	}
 
 	prev = NULL;


More information about the dovecot-cvs mailing list