dovecot-2.2: lib-master: Code cleanup - split master_status_upda...

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 17 09:57:12 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/10df63e74ed6
changeset: 18939:10df63e74ed6
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 17 12:51:43 2015 +0300
description:
lib-master: Code cleanup - split master_status_update() to two functions.
No functional changes.

diffstat:

 src/lib-master/master-service.c |  76 ++++++++++++++++++++++------------------
 1 files changed, 41 insertions(+), 35 deletions(-)

diffs (95 lines):

diff -r 38c3d7b44dd5 -r 10df63e74ed6 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Sun Aug 16 13:22:14 2015 +0200
+++ b/src/lib-master/master-service.c	Mon Aug 17 12:51:43 2015 +0300
@@ -991,9 +991,48 @@
 	return FALSE;
 }
 
+static void
+master_status_send(struct master_service *service, bool important_update)
+{
+	ssize_t ret;
+
+	if (service->to_status != NULL)
+		timeout_remove(&service->to_status);
+
+	ret = write(MASTER_STATUS_FD, &service->master_status,
+		    sizeof(service->master_status));
+	if (ret == sizeof(service->master_status)) {
+		/* success */
+		if (service->io_status_write != NULL) {
+			/* delayed important update sent successfully */
+			io_remove(&service->io_status_write);
+		}
+		service->last_sent_status_time = ioloop_time;
+		service->last_sent_status_avail_count =
+			service->master_status.available_count;
+		service->initial_status_sent = TRUE;
+	} else if (ret >= 0) {
+		/* shouldn't happen? */
+		i_error("write(master_status_fd) returned %d", (int)ret);
+		service->master_status.pid = 0;
+	} else if (errno != EAGAIN) {
+		/* failure */
+		if (errno != EPIPE)
+			i_error("write(master_status_fd) failed: %m");
+		service->master_status.pid = 0;
+	} else if (important_update) {
+		/* reader is busy, but it's important to get this notification
+		   through. send it when possible. */
+		if (service->io_status_write == NULL) {
+			service->io_status_write =
+				io_add(MASTER_STATUS_FD, IO_WRITE,
+				       master_status_update, service);
+		}
+	}
+}
+
 void master_status_update(struct master_service *service)
 {
-	ssize_t ret;
 	bool important_update;
 
 	if ((service->flags & MASTER_SERVICE_FLAG_UPDATE_PROCTITLE) != 0 &&
@@ -1030,40 +1069,7 @@
 			io_remove(&service->io_status_write);
 		return;
 	}
-
-	if (service->to_status != NULL)
-		timeout_remove(&service->to_status);
-
-	ret = write(MASTER_STATUS_FD, &service->master_status,
-		    sizeof(service->master_status));
-	if (ret == sizeof(service->master_status)) {
-		/* success */
-		if (service->io_status_write != NULL) {
-			/* delayed important update sent successfully */
-			io_remove(&service->io_status_write);
-		}
-		service->last_sent_status_time = ioloop_time;
-		service->last_sent_status_avail_count =
-			service->master_status.available_count;
-		service->initial_status_sent = TRUE;
-	} else if (ret >= 0) {
-		/* shouldn't happen? */
-		i_error("write(master_status_fd) returned %d", (int)ret);
-		service->master_status.pid = 0;
-	} else if (errno != EAGAIN) {
-		/* failure */
-		if (errno != EPIPE)
-			i_error("write(master_status_fd) failed: %m");
-		service->master_status.pid = 0;
-	} else if (important_update) {
-		/* reader is busy, but it's important to get this notification
-		   through. send it when possible. */
-		if (service->io_status_write == NULL) {
-			service->io_status_write =
-				io_add(MASTER_STATUS_FD, IO_WRITE,
-				       master_status_update, service);
-		}
-	}
+	master_status_send(service, important_update);
 }
 
 bool version_string_verify(const char *line, const char *service_name,


More information about the dovecot-cvs mailing list