dovecot-1.2: master: When shutting down, avoid dict processes gi...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jan 26 02:51:05 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/0e9b885bd29e
changeset: 8686:0e9b885bd29e
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jan 25 19:51:00 2009 -0500
description:
master: When shutting down, avoid dict processes giving "unknown process exited" errors.

diffstat:

1 file changed, 14 insertions(+), 7 deletions(-)
src/master/dict-process.c |   21 ++++++++++++++-------

diffs (63 lines):

diff -r 6ee78e18d026 -r 0e9b885bd29e src/master/dict-process.c
--- a/src/master/dict-process.c	Sun Jan 25 19:40:36 2009 -0500
+++ b/src/master/dict-process.c	Sun Jan 25 19:51:00 2009 -0500
@@ -27,7 +27,6 @@ struct dict_process {
 struct dict_process {
 	struct child_process process;
 	struct dict_process *next;
-	pid_t pid;
 
 	struct dict_listener *listener;
 	struct log_io *log;
@@ -65,7 +64,6 @@ static int dict_process_create(struct di
 
 	if (pid != 0) {
 		/* master */
-		process->pid = pid;
 		process->next = process->listener->processes;
 		process->listener->processes = process;
 
@@ -121,11 +119,18 @@ static int dict_process_create(struct di
 	return -1;
 }
 
+static void dict_listener_unref(struct dict_listener *listener)
+{
+	if (listener->processes == NULL)
+		i_free(listener);
+}
+
 static void dict_process_deinit(struct dict_process *process)
 {
+	struct dict_listener *listener = process->listener;
 	struct dict_process **p;
 
-	for (p = &process->listener->processes; *p != NULL; p = &(*p)->next) {
+	for (p = &listener->processes; *p != NULL; p = &(*p)->next) {
 		if (*p == process) {
 			*p = process->next;
 			break;
@@ -135,6 +140,8 @@ static void dict_process_deinit(struct d
 	if (process->log != NULL)
 		log_unref(process->log);
 	i_free(process);
+
+	dict_listener_unref(listener);
 }
 
 static void dict_listener_input(struct dict_listener *listener)
@@ -188,10 +195,10 @@ static void dict_listener_deinit(struct 
 	if (close(listener->fd) < 0)
 		i_error("close(dict listener) failed: %m");
 
-	while (listener->processes != NULL) {
-		child_process_remove(listener->processes->pid);
-		dict_process_deinit(listener->processes);
-	}
+	/* don't try to free the dict processes here,
+	   let dict_process_destroyed() do it to avoid "unknown child exited"
+	   errors. */
+	dict_listener_unref(listener);
 }
 
 static void


More information about the dovecot-cvs mailing list