Mercurial > dovecot > core-2.2
changeset 4149:b10fa8ba01ca HEAD
When master dies (by closing log file descriptor), kill ourself also.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 Apr 2006 17:48:23 +0300 |
parents | f60d73c96618 |
children | 49e024519e22 |
files | src/imap/main.c src/pop3/main.c |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/main.c Sun Apr 09 17:36:03 2006 +0300 +++ b/src/imap/main.c Sun Apr 09 17:48:23 2006 +0300 @@ -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();
--- a/src/pop3/main.c Sun Apr 09 17:36:03 2006 +0300 +++ b/src/pop3/main.c Sun Apr 09 17:48:23 2006 +0300 @@ -39,6 +39,8 @@ static struct module *modules; static char log_prefix[128]; /* syslog() needs this to be permanent */ +static struct io *log_io = NULL; + enum client_workarounds client_workarounds = 0; bool enable_last_command = FALSE; bool no_flag_updates = FALSE; @@ -55,6 +57,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; @@ -168,6 +175,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); + } + dict_client_register(); mail_storage_init(); mail_storage_register_all(); @@ -232,6 +245,8 @@ static void main_deinit(void) { + if (log_io != NULL) + io_remove(&log_io); module_dir_unload(&modules); clients_deinit();