dovecot-2.0: liblib: Delay sending log prefix updates until it's...

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 9 22:27:13 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e2a880387cca
changeset: 12407:e2a880387cca
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 09 20:25:36 2010 +0000
description:
liblib: Delay sending log prefix updates until it's needed.
This avoids sending them unnecessarily.

diffstat:

 src/lib/failures.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r fa911bf1cbee -r e2a880387cca src/lib/failures.c
--- a/src/lib/failures.c	Tue Nov 09 20:24:12 2010 +0000
+++ b/src/lib/failures.c	Tue Nov 09 20:25:36 2010 +0000
@@ -42,7 +42,7 @@
 static int log_fd = STDERR_FILENO, log_info_fd = STDERR_FILENO,
 	   log_debug_fd = STDERR_FILENO;
 static char *log_prefix = NULL, *log_stamp_format = NULL;
-static bool failure_ignore_errors = FALSE;
+static bool failure_ignore_errors = FALSE, log_prefix_sent = FALSE;
 
 static void ATTR_FORMAT(2, 0)
 i_internal_error_handler(const struct failure_context *ctx,
@@ -523,7 +523,7 @@
 	i_free(log_prefix);
 	log_prefix = i_strdup(prefix);
 
-	i_failure_send_option("prefix", prefix);
+	log_prefix_sent = FALSE;
 }
 
 static int internal_send_split(string_t *full_str, unsigned int prefix_len)
@@ -565,6 +565,11 @@
 		string_t *str;
 		unsigned int prefix_len;
 
+		if (!log_prefix_sent) {
+			log_prefix_sent = TRUE;
+			i_failure_send_option("prefix", log_prefix);
+		}
+
 		str = t_str_new(128);
 		str_printfa(str, "\001%c%s ", ctx->type + 1, my_pid);
 		prefix_len = str_len(str);


More information about the dovecot-cvs mailing list