dovecot-2.2: lib-lda: Assume that the caller sets delivery_time_...

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


details:   http://hg.dovecot.org/dovecot-2.2/rev/7ef1722d8f7a
changeset: 18437:7ef1722d8f7a
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 21 16:54:51 2015 +0300
description:
lib-lda: Assume that the caller sets delivery_time_started
This is required because parts of the delivery time may be done at the time
the user is being initialized, so it needs to be set before the user init is
done.

diffstat:

 src/lda/main.c             |  4 ++++
 src/lib-lda/mail-deliver.c |  3 ---
 src/lmtp/commands.c        |  6 ++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diffs (64 lines):

diff -r 6ecca5308232 -r 7ef1722d8f7a src/lda/main.c
--- a/src/lda/main.c	Tue Apr 21 16:52:59 2015 +0300
+++ b/src/lda/main.c	Tue Apr 21 16:54:51 2015 +0300
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "lib-signals.h"
+#include "ioloop.h"
 #include "env-util.h"
 #include "fd-set-nonblock.h"
 #include "istream.h"
@@ -409,6 +410,9 @@
 		MAIL_STORAGE_SERVICE_FLAG_USE_SYSEXITS;
 	storage_service = mail_storage_service_init(master_service, set_roots,
 						    service_flags);
+	/* set before looking up the user (or ideally we'd do this between
+	   _lookup() and _next(), but don't bother) */
+	ctx.delivery_time_started = ioloop_timeval;
 	ret = mail_storage_service_lookup_next(storage_service, &service_input,
 					       &service_user, &ctx.dest_user,
 					       &errstr);
diff -r 6ecca5308232 -r 7ef1722d8f7a src/lib-lda/mail-deliver.c
--- a/src/lib-lda/mail-deliver.c	Tue Apr 21 16:52:59 2015 +0300
+++ b/src/lib-lda/mail-deliver.c	Tue Apr 21 16:54:51 2015 +0300
@@ -430,9 +430,6 @@
 {
 	int ret;
 
-	io_loop_time_refresh();
-	ctx->delivery_time_started = ioloop_timeval;
-
 	*storage_r = NULL;
 	if (deliver_mail == NULL)
 		ret = -1;
diff -r 6ecca5308232 -r 7ef1722d8f7a src/lmtp/commands.c
--- a/src/lmtp/commands.c	Tue Apr 21 16:52:59 2015 +0300
+++ b/src/lmtp/commands.c	Tue Apr 21 16:54:51 2015 +0300
@@ -750,6 +750,7 @@
 	struct lda_settings *lda_set;
 	struct mail_namespace *ns;
 	struct setting_parser_context *set_parser;
+	struct timeval delivery_time_started;
 	void **sets;
 	const char *line, *error, *username;
 	string_t *str;
@@ -785,6 +786,10 @@
 			i_unreached();
 	}
 
+	/* get the timestamp before user is created, since it starts the I/O */
+	io_loop_time_refresh();
+	delivery_time_started = ioloop_timeval;
+
 	client_state_set(client, "DATA", username);
 	i_set_failure_prefix("lmtp(%s, %s): ", my_pid, username);
 	if (mail_storage_service_next(storage_service, rcpt->service_user,
@@ -815,6 +820,7 @@
 	dctx.session_time_msecs =
 		timeval_diff_msecs(&client->state.data_end_timeval,
 				   &client->state.mail_from_timeval);
+	dctx.delivery_time_started = delivery_time_started;
 
 	if (orcpt_get_valid_rfc822(rcpt->params.dsn_orcpt, &dctx.dest_addr)) {
 		/* used ORCPT */


More information about the dovecot-cvs mailing list