]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail-log: Add mail_log_cached_only setting.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 15 Feb 2017 21:32:52 +0000 (23:32 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 15 Feb 2017 21:32:52 +0000 (23:32 +0200)
If enabled, everything except "save" event will log only the fields that can
be looked up from cache. This improves performance if some of the fields
aren't cached and it's not a strict requirement to log them.

src/plugins/mail-log/mail-log-plugin.c

index 4bc9427efcc01d2b6dac299a91462f564b246dc0..bc4e87a79d3ef7230c298cecbad84dd447f5f6d2 100644 (file)
@@ -78,6 +78,7 @@ struct mail_log_user {
 
        enum mail_log_field fields;
        enum mail_log_event events;
+       bool cached_only;
 };
 
 struct mail_log_message {
@@ -165,6 +166,9 @@ static void mail_log_mail_user_created(struct mail_user *user)
        str = mail_user_plugin_getenv(user, "mail_log_events");
        muser->events = str == NULL ? MAIL_LOG_DEFAULT_EVENTS :
                mail_log_parse_events(str);
+
+       muser->cached_only =
+               mail_user_plugin_getenv_bool(user, "mail_log_cached_only");
 }
 
 static void mail_log_append_mailbox_name(string_t *str, struct mail *mail)
@@ -333,7 +337,12 @@ mail_log_append_mail_message(struct mail_log_mail_txn_context *ctx,
        }
 
        T_BEGIN {
+               enum mail_lookup_abort orig_lookup_abort = mail->lookup_abort;
+
+               if (event != MAIL_LOG_EVENT_SAVE && muser->cached_only)
+                       mail->lookup_abort = MAIL_LOOKUP_ABORT_NOT_IN_CACHE;
                mail_log_append_mail_message_real(ctx, mail, event, desc);
+               mail->lookup_abort = orig_lookup_abort;
        } T_END;
 }