changeset 9955:907e781f7999 HEAD

master: Fix to previous change, don't crash at service deinit.
author Timo Sirainen <tss@iki.fi>
date Wed, 30 Sep 2009 13:09:18 -0400
parents c998a51b7be4
children 3441e6613ab4
files src/master/service-anvil.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/service-anvil.c	Wed Sep 30 13:03:07 2009 -0400
+++ b/src/master/service-anvil.c	Wed Sep 30 13:09:18 2009 -0400
@@ -14,6 +14,15 @@
 #define ANVIL_HANDSHAKE "VERSION\tanvil\t1\t0\n"
 
 static void
+service_list_anvil_discard_input_stop(struct service_list *service_list)
+{
+	if (service_list->anvil_io_blocking != NULL) {
+		io_remove(&service_list->anvil_io_blocking);
+		io_remove(&service_list->anvil_io_nonblocking);
+	}
+}
+
+static void
 anvil_input_fd_discard(struct service_list *service_list, int fd)
 {
 	char buf[1024];
@@ -22,8 +31,7 @@
 	ret = read(fd, buf, sizeof(buf));
 	if (ret <= 0) {
 		i_error("read(anvil fd) failed: %m");
-		io_remove(&service_list->anvil_io_blocking);
-		io_remove(&service_list->anvil_io_nonblocking);
+		service_list_anvil_discard_input_stop(service_list);
 	}
 }
 
@@ -118,6 +126,7 @@
 
 void service_list_deinit_anvil(struct service_list *service_list)
 {
+	service_list_anvil_discard_input_stop(service_list);
 	service_process_notify_deinit(&service_list->anvil_kills);
 	if (close(service_list->blocking_anvil_fd[0]) < 0)
 		i_error("close(anvil) failed: %m");
@@ -131,10 +140,7 @@
 
 void service_anvil_process_created(struct service *service)
 {
-	if (service->list->anvil_io_blocking != NULL) {
-		io_remove(&service->list->anvil_io_blocking);
-		io_remove(&service->list->anvil_io_nonblocking);
-	}
+	service_list_anvil_discard_input_stop(service->list);
 }
 
 void service_anvil_process_destroyed(struct service *service)