changeset 9992:fb16190aa088 HEAD

master: Fixes to handling anvil service.
author Timo Sirainen <tss@iki.fi>
date Wed, 07 Oct 2009 20:35:37 -0400
parents e19832d735aa
children 33532261ce0c
files src/master/service-anvil.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/service-anvil.c	Wed Oct 07 20:31:17 2009 -0400
+++ b/src/master/service-anvil.c	Wed Oct 07 20:35:37 2009 -0400
@@ -32,6 +32,8 @@
 	if (ret <= 0) {
 		i_error("read(anvil fd) failed: %m");
 		service_list_anvil_discard_input_stop(service_list);
+	} else {
+		i_warning("discarded %.*s", (int)ret, buf);
 	}
 }
 
@@ -109,13 +111,6 @@
 	fd_close_on_exec(service_list->nonblocking_anvil_fd[0], TRUE);
 	fd_close_on_exec(service_list->nonblocking_anvil_fd[1], TRUE);
 
-	if (anvil_send_handshake(service_list->blocking_anvil_fd[1],
-				 error_r) < 0)
-		return -1;
-	if (anvil_send_handshake(service_list->nonblocking_anvil_fd[1],
-				 error_r) < 0)
-		return -1;
-
 	i_assert(service_list->anvil_kills == NULL);
 	service_list->anvil_kills =
 		service_process_notify_init(service_list->nonblocking_anvil_fd[1],
@@ -136,16 +131,25 @@
 		i_error("close(anvil) failed: %m");
 	if (close(service_list->nonblocking_anvil_fd[1]) < 0)
 		i_error("close(anvil) failed: %m");
+	service_list->blocking_anvil_fd[0] = -1;
 }
 
 void service_anvil_process_created(struct service *service)
 {
+	struct service_list *list = service->list;
+	const char *error;
+
 	service_list_anvil_discard_input_stop(service->list);
+
+	if (anvil_send_handshake(list->blocking_anvil_fd[1], &error) < 0 ||
+	    anvil_send_handshake(list->nonblocking_anvil_fd[1], &error) < 0)
+		service_error(service, "%s", error);
 }
 
 void service_anvil_process_destroyed(struct service *service)
 {
 	if (service->process_count == 0 &&
-	    service->list->anvil_io_blocking == NULL)
+	    service->list->anvil_io_blocking == NULL &&
+	    service->list->blocking_anvil_fd[0] != -1)
 		service_list_anvil_discard_input(service->list);
 }