dovecot-2.0: anvil: Stop immediately when master asks, instead o...

dovecot at dovecot.org dovecot at dovecot.org
Sat Sep 5 00:34:25 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/cce684dfe3e7
changeset: 9880:cce684dfe3e7
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 04 17:34:18 2009 -0400
description:
anvil: Stop immediately when master asks, instead of waiting for clients to finish.

diffstat:

3 files changed, 15 insertions(+), 3 deletions(-)
src/anvil/main.c                |    1 +
src/lib-master/master-service.c |    9 +++++++--
src/login-common/sasl-server.c  |    8 +++++++-

diffs (50 lines):

diff -r e11bd2547bb2 -r cce684dfe3e7 src/anvil/main.c
--- a/src/anvil/main.c	Fri Sep 04 17:33:00 2009 -0400
+++ b/src/anvil/main.c	Fri Sep 04 17:34:18 2009 -0400
@@ -30,6 +30,7 @@ int main(int argc, char *argv[])
 			exit(FATAL_DEFAULT);
 	}
 
+	master_service_set_die_with_master(master_service, TRUE);
 	master_service_init_log(master_service, "anvil: ", 0);
 	master_service_init_finish(master_service);
 	connect_limit = connect_limit_init();
diff -r e11bd2547bb2 -r cce684dfe3e7 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Fri Sep 04 17:33:00 2009 -0400
+++ b/src/lib-master/master-service.c	Fri Sep 04 17:34:18 2009 -0400
@@ -416,9 +416,14 @@ void master_service_anvil_send(struct ma
 		return;
 
 	ret = write(MASTER_ANVIL_FD, cmd, strlen(cmd));
-	if (ret < 0)
+	if (ret < 0) {
+		if (errno == EPIPE) {
+			/* anvil process was probably recreated, don't bother
+			   logging an error about losing connection to it */
+			return;
+		}
 		i_error("write(anvil) failed: %m");
-	else if (ret == 0)
+	} else if (ret == 0)
 		i_error("write(anvil) failed: EOF");
 	else {
 		i_assert((size_t)ret == strlen(cmd));
diff -r e11bd2547bb2 -r cce684dfe3e7 src/login-common/sasl-server.c
--- a/src/login-common/sasl-server.c	Fri Sep 04 17:33:00 2009 -0400
+++ b/src/login-common/sasl-server.c	Fri Sep 04 17:34:18 2009 -0400
@@ -138,8 +138,14 @@ static bool anvil_has_too_many_connectio
 	ident = t_strconcat("LOOKUP\t", net_ip2addr(&client->ip), "/",
 			    str_tabescape(client->virtual_user), "/",
 			    login_protocol, "\n", NULL);
-	if (write_full(anvil_fd, ident, strlen(ident)) < 0)
+	if (write_full(anvil_fd, ident, strlen(ident)) < 0) {
+		if (errno == EPIPE) {
+			/* anvil process was probably recreated, don't bother
+			   logging an error about losing connection to it */
+			return FALSE;
+		}
 		i_fatal("write(anvil) failed: %m");
+	}
 	ret = read(anvil_fd, buf, sizeof(buf)-1);
 	if (ret < 0)
 		i_fatal("read(anvil) failed: %m");


More information about the dovecot-cvs mailing list