From: Timo Sirainen Date: Tue, 9 Nov 2010 20:25:36 +0000 (+0000) Subject: liblib: Delay sending log prefix updates until it's needed. X-Git-Tag: 2.0.8~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc2a751e24043843b807e9fce18dec2bfd8b8de1;p=thirdparty%2Fdovecot%2Fcore.git liblib: Delay sending log prefix updates until it's needed. This avoids sending them unnecessarily. --- diff --git a/src/lib/failures.c b/src/lib/failures.c index e27c5ae9c4..ff15bc6b15 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -42,7 +42,7 @@ static struct failure_context failure_ctx_error = { .type = LOG_TYPE_ERROR }; 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 @@ void i_set_failure_prefix(const char *prefix) 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 @@ internal_handler(const struct failure_context *ctx, 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);