dovecot-2.2: lib-lda: mail_deliver_log() now updates the %{deliv...

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 21 14:03:22 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/6ecca5308232
changeset: 18436:6ecca5308232
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 21 16:52:59 2015 +0300
description:
lib-lda: mail_deliver_log() now updates the %{delivery_time} instead of using the first cached value.
The first time the cached values are set the transaction isn't committed and
the mailbox isn't synced.

diffstat:

 src/lib-lda/mail-deliver.c |  23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diffs (49 lines):

diff -r 860af8c30c59 -r 6ecca5308232 src/lib-lda/mail-deliver.c
--- a/src/lib-lda/mail-deliver.c	Tue Apr 21 16:50:43 2015 +0300
+++ b/src/lib-lda/mail-deliver.c	Tue Apr 21 16:52:59 2015 +0300
@@ -39,6 +39,19 @@
 		NULL : t_strconcat(addr->mailbox, "@", addr->domain, NULL);
 }
 
+static void
+mail_deliver_log_var_expand_table_update_times(struct mail_deliver_context *ctx,
+					       struct var_expand_table *tab)
+{
+#define VAR_EXPAND_SESSION_TIME_IDX 7
+	int delivery_time_msecs;
+
+	io_loop_time_refresh();
+	delivery_time_msecs = timeval_diff_msecs(&ioloop_timeval,
+						 &ctx->delivery_time_started);
+	tab[VAR_EXPAND_SESSION_TIME_IDX].value = dec2str(delivery_time_msecs);
+}
+
 static const struct var_expand_table *
 mail_deliver_get_log_var_expand_table_full(struct mail_deliver_context *ctx,
 					   struct mail *mail,
@@ -81,13 +94,7 @@
 	if (mail_get_virtual_size(mail, &size) == 0)
 		tab[6].value = dec2str(size);
 	if (ctx != NULL) {
-		int delivery_time_msecs;
-
-		io_loop_time_refresh();
-		delivery_time_msecs =
-			timeval_diff_msecs(&ioloop_timeval,
-					   &ctx->delivery_time_started);
-		tab[7].value = dec2str(delivery_time_msecs);
+		mail_deliver_log_var_expand_table_update_times(ctx, tab);
 		tab[8].value = dec2str(ctx->session_time_msecs);
 	}
 	return tab;
@@ -147,8 +154,10 @@
 		mail_deliver_log_cache_var_expand_table(ctx);
 	/* update %$ */
 	ctx->var_expand_table[0].value = msg;
+	mail_deliver_log_var_expand_table_update_times(ctx, ctx->var_expand_table);
 	var_expand(str, ctx->set->deliver_log_format, ctx->var_expand_table);
 	ctx->var_expand_table[0].value = "";
+	ctx->var_expand_table[VAR_EXPAND_SESSION_TIME_IDX].value = "";
 
 	i_info("%s", str_c(str));
 	va_end(args);


More information about the dovecot-cvs mailing list