dovecot-2.0: master: Use per-services_list "master is dead" fd, ...

dovecot at dovecot.org dovecot at dovecot.org
Fri Mar 4 20:37:05 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/539da23bff31
changeset: 12650:539da23bff31
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 04 20:37:03 2011 +0200
description:
master: Use per-services_list "master is dead" fd, so services know when config is reload.

diffstat:

 src/master/common.h          |   2 +-
 src/master/main.c            |   8 ++++----
 src/master/service-monitor.c |  14 ++++++++++++++
 src/master/service-process.c |   8 +++++++-
 src/master/service.c         |   2 ++
 src/master/service.h         |   2 ++
 6 files changed, 30 insertions(+), 6 deletions(-)

diffs (111 lines):

diff -r 65e943eafe8b -r 539da23bff31 src/master/common.h
--- a/src/master/common.h	Fri Mar 04 20:01:03 2011 +0200
+++ b/src/master/common.h	Fri Mar 04 20:37:03 2011 +0200
@@ -9,7 +9,7 @@
 extern gid_t master_gid;
 extern bool core_dumps_disabled;
 extern const char *ssl_manual_key_password;
-extern int null_fd, master_dead_pipe_fd[2];
+extern int null_fd, global_master_dead_pipe_fd[2];
 extern struct service_list *services;
 
 void process_exec(const char *cmd, const char *extra_args[]) ATTR_NORETURN;
diff -r 65e943eafe8b -r 539da23bff31 src/master/main.c
--- a/src/master/main.c	Fri Mar 04 20:01:03 2011 +0200
+++ b/src/master/main.c	Fri Mar 04 20:37:03 2011 +0200
@@ -42,7 +42,7 @@
 gid_t master_gid;
 bool core_dumps_disabled;
 const char *ssl_manual_key_password;
-int null_fd, master_dead_pipe_fd[2];
+int null_fd, global_master_dead_pipe_fd[2];
 struct service_list *services;
 
 static char *pidfile_path;
@@ -725,10 +725,10 @@
 			i_fatal("Can't open /dev/null: %m");
 		fd_close_on_exec(null_fd, TRUE);
 	} while (null_fd <= STDERR_FILENO);
-	if (pipe(master_dead_pipe_fd) < 0)
+	if (pipe(global_master_dead_pipe_fd) < 0)
 		i_fatal("pipe() failed: %m");
-	fd_close_on_exec(master_dead_pipe_fd[0], TRUE);
-	fd_close_on_exec(master_dead_pipe_fd[1], TRUE);
+	fd_close_on_exec(global_master_dead_pipe_fd[0], TRUE);
+	fd_close_on_exec(global_master_dead_pipe_fd[1], TRUE);
 
 	set = master_settings_read();
 	if (ask_key_pass) {
diff -r 65e943eafe8b -r 539da23bff31 src/master/service-monitor.c
--- a/src/master/service-monitor.c	Fri Mar 04 20:01:03 2011 +0200
+++ b/src/master/service-monitor.c	Fri Mar 04 20:37:03 2011 +0200
@@ -344,6 +344,11 @@
 	services_log_init(service_list);
 	service_anvil_monitor_start(service_list);
 
+	if (pipe(service_list->master_dead_pipe_fd) < 0)
+		i_error("pipe() failed: %m");
+	fd_close_on_exec(service_list->master_dead_pipe_fd[0], TRUE);
+	fd_close_on_exec(service_list->master_dead_pipe_fd[1], TRUE);
+
 	array_foreach(&service_list->services, services) {
 		struct service *service = *services;
 
@@ -422,6 +427,15 @@
 {
 	struct service *const *services;
 
+	if (service_list->master_dead_pipe_fd[0] != -1) {
+		if (close(service_list->master_dead_pipe_fd[0]) < 0)
+			i_error("close(master dead pipe) failed: %m");
+		if (close(service_list->master_dead_pipe_fd[1]) < 0)
+			i_error("close(master dead pipe) failed: %m");
+		service_list->master_dead_pipe_fd[0] = -1;
+		service_list->master_dead_pipe_fd[1] = -1;
+	}
+
 	array_foreach(&service_list->services, services)
 		service_monitor_stop(*services);
 
diff -r 65e943eafe8b -r 539da23bff31 src/master/service-process.c
--- a/src/master/service-process.c	Fri Mar 04 20:01:03 2011 +0200
+++ b/src/master/service-process.c	Fri Mar 04 20:37:03 2011 +0200
@@ -116,7 +116,13 @@
 		break;
 	}
 	dup2_append(&dups, service->status_fd[1], MASTER_STATUS_FD);
-	dup2_append(&dups, master_dead_pipe_fd[1], MASTER_DEAD_FD);
+	if (service->type != SERVICE_TYPE_ANVIL) {
+		dup2_append(&dups, service->list->master_dead_pipe_fd[1],
+			    MASTER_DEAD_FD);
+	} else {
+		dup2_append(&dups, global_master_dead_pipe_fd[1],
+			    MASTER_DEAD_FD);
+	}
 
 	if (service->type == SERVICE_TYPE_LOG) {
 		/* keep stderr as-is. this is especially important when
diff -r 65e943eafe8b -r 539da23bff31 src/master/service.c
--- a/src/master/service.c	Fri Mar 04 20:01:03 2011 +0200
+++ b/src/master/service.c	Fri Mar 04 20:37:03 2011 +0200
@@ -444,6 +444,8 @@
 	service_list->set = set;
 	service_list->master_log_fd[0] = -1;
 	service_list->master_log_fd[1] = -1;
+	service_list->master_dead_pipe_fd[0] = -1;
+	service_list->master_dead_pipe_fd[1] = -1;
 
 	service_settings = array_get(&set->services, &count);
 	p_array_init(&service_list->services, pool, count);
diff -r 65e943eafe8b -r 539da23bff31 src/master/service.h
--- a/src/master/service.h	Fri Mar 04 20:01:03 2011 +0200
+++ b/src/master/service.h	Fri Mar 04 20:37:03 2011 +0200
@@ -119,6 +119,8 @@
 	int master_log_fd[2];
 	struct service_process_notify *log_byes;
 
+	int master_dead_pipe_fd[2];
+
 	ARRAY_DEFINE(services, struct service *);
 
 	unsigned int destroyed:1;


More information about the dovecot-cvs mailing list