]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3/imap: When master closes our log fd, don't die when trying to log disconnect...
authorTimo Sirainen <tss@iki.fi>
Tue, 10 Feb 2009 17:19:05 +0000 (12:19 -0500)
committerTimo Sirainen <tss@iki.fi>
Tue, 10 Feb 2009 17:19:05 +0000 (12:19 -0500)
--HG--
branch : HEAD

src/dict/main.c
src/imap/main.c
src/lib/failures.c
src/lib/failures.h
src/pop3/main.c

index 55429a79eb31438fe894e237581cefb549c698f2..7666820e502d0ec2a3d84e8ea67021cf5cb23ad7 100644 (file)
@@ -34,6 +34,9 @@ static void sig_die(int signo, void *context ATTR_UNUSED)
 
 static void log_error_callback(void *context ATTR_UNUSED)
 {
+       /* the log fd is closed, don't die when trying to log later */
+       i_set_failure_ignore_errors(TRUE);
+
        io_loop_stop(ioloop);
 }
 
index 13420dd27ed3799c9179cb292974e3d2d3768218..a1a351dc96da126412bcc6ab5d699cb7431b06fc 100644 (file)
@@ -63,6 +63,9 @@ static void sig_die(int signo, void *context ATTR_UNUSED)
 
 static void log_error_callback(void *context ATTR_UNUSED)
 {
+       /* the log fd is closed, don't die when trying to log later */
+       i_set_failure_ignore_errors(TRUE);
+
        io_loop_stop(ioloop);
 }
 
index 8c24e1cbb86ac457982fdb31733472122a0a3e36..a4de26c7951e65a9b4315e3e0994c6a22f929cfb 100644 (file)
@@ -35,6 +35,7 @@ static void (*failure_exit_callback)(int *) = NULL;
 
 static int log_fd = STDERR_FILENO, log_info_fd = STDERR_FILENO;
 static char *log_prefix = NULL, *log_stamp_format = NULL;
+static bool failure_ignore_errors = FALSE;
 
 /* kludgy .. we want to trust log_stamp_format with -Wformat-nonliteral */
 static const char *get_log_stamp_format(const char *unused)
@@ -133,6 +134,9 @@ default_handler(const char *prefix, int fd, const char *format, va_list args)
                ret = log_fd_write(fd, str_data(str), str_len(str));
        } T_END;
 
+       if (ret < 0 && failure_ignore_errors)
+               ret = 0;
+
        recursed--;
        return ret;
 }
@@ -413,6 +417,9 @@ internal_handler(char log_type, const char *format, va_list args)
                ret = write_full(2, str_data(str), str_len(str));
        } T_END;
 
+       if (ret < 0 && failure_ignore_errors)
+               ret = 0;
+
        recursed--;
        return ret;
 }
@@ -442,6 +449,11 @@ void i_set_failure_internal(void)
        i_set_info_handler(i_internal_error_handler);
 }
 
+void i_set_failure_ignore_errors(bool ignore)
+{
+       failure_ignore_errors = ignore;
+}
+
 void i_set_info_file(const char *path)
 {
        if (log_info_fd == log_fd)
index 1570e73ecf3a49aac434b67e42cdcc9ca0fa7e57..1c7c3a3235829a74e9f89e5677013884bb0ba120 100644 (file)
@@ -73,6 +73,9 @@ void i_set_failure_file(const char *path, const char *prefix);
 
 /* Send errors to stderr using internal error protocol. */
 void i_set_failure_internal(void);
+/* If writing to log fails, ignore it instead of existing with
+   FATAL_LOGWRITE or FATAL_LOGERROR. */
+void i_set_failure_ignore_errors(bool ignore);
 
 /* Send informational messages to specified log file. i_set_failure_*()
    functions modify the info file too, so call this function after them. */
index 55873501a4094370723b098d95e28664c0cb14e6..0aeb51c957b57093813ecc112cc8f297fba4dd7d 100644 (file)
@@ -63,6 +63,9 @@ static void sig_die(int signo, void *context ATTR_UNUSED)
 
 static void log_error_callback(void *context ATTR_UNUSED)
 {
+       /* the log fd is closed, don't die when trying to log later */
+       i_set_failure_ignore_errors(TRUE);
+
        io_loop_stop(ioloop);
 }