[dovecot-cvs] dovecot/src/imap main.c,1.72,1.73

cras at dovecot.org cras at dovecot.org
Sun Apr 9 17:48:25 EEST 2006


Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv14990/imap

Modified Files:
	main.c 
Log Message:
When master dies (by closing log file descriptor), kill ourself also.



Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/main.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- main.c	26 Feb 2006 12:15:45 -0000	1.72
+++ main.c	9 Apr 2006 14:48:23 -0000	1.73
@@ -41,6 +41,7 @@
 unsigned int max_keyword_length;
 unsigned int imap_max_line_length;
 enum client_workarounds client_workarounds = 0;
+static struct io *log_io = NULL;
 
 static struct module *modules;
 static char log_prefix[128]; /* syslog() needs this to be permanent */
@@ -60,6 +61,11 @@
 	io_loop_stop(ioloop);
 }
 
+static void log_error_callback(void *context __attr_unused__)
+{
+	io_loop_stop(ioloop);
+}
+
 static void parse_workarounds(void)
 {
         struct client_workaround_list *list;
@@ -156,6 +162,12 @@
 		       dec2str(geteuid()), dec2str(getegid()));
 	}
 
+	if (getenv("LOG_TO_MASTER") != 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);
+	}
+
 	capability_string = str_new(default_pool, sizeof(CAPABILITY_STRING)+32);
 	str_append(capability_string, CAPABILITY_STRING);
 
@@ -205,6 +217,8 @@
 
 static void main_deinit(void)
 {
+	if (log_io != NULL)
+		io_remove(&log_io);
 	module_dir_unload(&modules);
 
 	commands_deinit();



More information about the dovecot-cvs mailing list