changeset 9880:cce684dfe3e7 HEAD

anvil: Stop immediately when master asks, instead of waiting for clients to finish.
author Timo Sirainen <tss@iki.fi>
date Fri, 04 Sep 2009 17:34:18 -0400
parents e11bd2547bb2
children 8ad868df4649
files src/anvil/main.c src/lib-master/master-service.c src/login-common/sasl-server.c
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 			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();
--- 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 @@
 		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));
--- 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 @@
 	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");