dovecot-2.0: lib-master: Try to send master status more reliably.

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 9 22:42:19 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/67b8de25154c
changeset: 11516:67b8de25154c
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 09 20:42:14 2010 +0100
description:
lib-master: Try to send master status more reliably.

diffstat:

 src/lib-master/master-service-private.h |   1 -
 src/lib-master/master-service.c         |  17 +++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diffs (73 lines):

diff -r e3d2d9427d3d -r 67b8de25154c src/lib-master/master-service-private.h
--- a/src/lib-master/master-service-private.h	Wed Jun 09 19:47:25 2010 +0100
+++ b/src/lib-master/master-service-private.h	Wed Jun 09 20:42:14 2010 +0100
@@ -59,7 +59,6 @@
 	unsigned int initial_status_sent:1;
 	unsigned int die_with_master:1;
 	unsigned int call_avail_overflow:1;
-	unsigned int delay_status_updates:1;
 	unsigned int config_path_is_default:1;
 };
 
diff -r e3d2d9427d3d -r 67b8de25154c src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Wed Jun 09 19:47:25 2010 +0100
+++ b/src/lib-master/master-service.c	Wed Jun 09 20:42:14 2010 +0100
@@ -675,11 +675,8 @@
 		/* we are full. stop listening for now, unless overflow
 		   callback destroys one of the existing connections */
 		if (service->call_avail_overflow &&
-		    service->avail_overflow_callback != NULL) {
-			service->delay_status_updates = TRUE;
+		    service->avail_overflow_callback != NULL)
 			service->avail_overflow_callback();
-			service->delay_status_updates = FALSE;
-		}
 
 		if (service->master_status.available_count == 0) {
 			master_service_io_listeners_remove(service);
@@ -817,12 +814,14 @@
 	bool important_update;
 
 	important_update = master_status_update_is_important(service);
-	if (service->master_status.pid == 0 || service->delay_status_updates ||
+	if (service->master_status.pid == 0 ||
 	    service->master_status.available_count ==
 	    service->last_sent_status_avail_count) {
 		/* a) closed, b) updating to same state */
 		if (service->to_status != NULL)
 			timeout_remove(&service->to_status);
+		if (service->io_status_write != NULL)
+			io_remove(&service->io_status_write);
 		return;
 	}
 	if (ioloop_time == service->last_sent_status_time &&
@@ -835,6 +834,8 @@
 				timeout_add(1000, master_status_update,
 					    service);
 		}
+		if (service->io_status_write != NULL)
+			io_remove(&service->io_status_write);
 		return;
 	}
 
@@ -843,7 +844,7 @@
 
 	ret = write(MASTER_STATUS_FD, &service->master_status,
 		    sizeof(service->master_status));
-	if (ret > 0) {
+	if (ret == sizeof(service->master_status)) {
 		/* success */
 		if (service->io_status_write != NULL) {
 			/* delayed important update sent successfully */
@@ -853,9 +854,9 @@
 		service->last_sent_status_avail_count =
 			service->master_status.available_count;
 		service->initial_status_sent = TRUE;
-	} else if (ret == 0) {
+	} else if (ret >= 0) {
 		/* shouldn't happen? */
-		i_error("write(master_status_fd) returned 0");
+		i_error("write(master_status_fd) returned %d", (int)ret);
 		service->master_status.pid = 0;
 	} else if (errno != EAGAIN) {
 		/* failure */


More information about the dovecot-cvs mailing list