dovecot-2.2: lib-master: If service_count=1, close the listener ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 23 16:15:52 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/459ec8f7ac96
changeset: 16873:459ec8f7ac96
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 23 16:10:30 2013 +0300
description:
lib-master: If service_count=1, close the listener before starting to handle the connection.
This way if the connection handling takes a long time and the service
doesn't notice that master dies, it can keep running without keeping the
listener fds open and preventing a restart.

diffstat:

 src/lib-master/master-service.c |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r e1dc6989b2c0 -r 459ec8f7ac96 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Wed Oct 23 15:36:02 2013 +0300
+++ b/src/lib-master/master-service.c	Wed Oct 23 16:10:30 2013 +0300
@@ -638,6 +638,15 @@
 	i_assert(service->master_status.available_count > 0);
 	service->master_status.available_count--;
 	master_status_update(service);
+
+	if (service->master_status.available_count == 0 &&
+	    service->service_count_left == 1) {
+		/* we're not going to accept any more connections after this.
+		   go ahead and close the connection early. */
+		i_assert(service->listeners != NULL);
+		master_service_io_listeners_remove(service);
+		master_service_io_listeners_close(service);
+	}
 }
 
 void master_service_client_connection_accept(struct master_service_connection *conn)
@@ -923,6 +932,7 @@
 					i_error("close(listener %d) failed: %m",
 						service->listeners[i].fd);
 				}
+				service->listeners[i].fd = -1;
 			}
 		}
 	} else {


More information about the dovecot-cvs mailing list