[dovecot-cvs] dovecot/src/dict main.c,1.8,1.9

cras at dovecot.org cras at dovecot.org
Sat Jun 17 14:24:12 EEST 2006


Update of /var/lib/cvs/dovecot/src/dict
In directory talvi:/tmp/cvs-serv7025

Modified Files:
	main.c 
Log Message:
Make sure the process dies when the master process dies.   



Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- main.c	3 May 2006 22:58:54 -0000	1.8
+++ main.c	17 Jun 2006 11:24:10 -0000	1.9
@@ -13,12 +13,14 @@
 #include "module-dir.h"
 
 #include <stdlib.h>
+#include <unistd.h>
 #include <syslog.h>
 
 #define DICT_MASTER_LISTENER_FD 3
 
 struct ioloop *ioloop;
 
+static struct io *log_io;
 static struct module *modules;
 static struct dict_server *dict_server;
 
@@ -31,6 +33,11 @@
 	io_loop_stop(ioloop);
 }
 
+static void log_error_callback(void *context __attr_unused__)
+{
+	io_loop_stop(ioloop);
+}
+
 static void drop_privileges(void)
 {
 	/* Log file or syslog opening probably requires roots */
@@ -58,6 +65,9 @@
         lib_signals_ignore(SIGPIPE);
         lib_signals_set_handler(SIGALRM, FALSE, NULL, NULL);
 
+	/* If master dies, the log fd gets closed and we'll quit */
+	log_io = io_add(STDERR_FILENO, IO_ERROR, log_error_callback, NULL);
+
 	dict_client_register();
 	dict_sql_register();
 
@@ -74,6 +84,7 @@
 
 static void main_deinit(void)
 {
+	io_remove(&log_io);
 	dict_server_deinit(dict_server);
 
 	module_dir_unload(&modules);



More information about the dovecot-cvs mailing list