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

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


details:   http://hg.dovecot.org/dovecot-1.0/rev/6ca86ec5a992
changeset: 5512:6ca86ec5a992
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jan 16 18:41:06 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 98fcc1dbdbf4 -r 6ca86ec5a992 src/master/master-settings.c
--- a/src/master/master-settings.c	Wed Jan 09 05:07:31 2008 +0200
+++ b/src/master/master-settings.c	Wed Jan 16 18:41:06 2008 +0200
@@ -831,7 +831,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;
@@ -840,9 +840,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));
@@ -850,7 +849,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;
 
@@ -860,15 +859,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 *
@@ -1357,8 +1353,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