]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add mail.mail_stream_opened and .mail_metadata_accessed
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 17 Feb 2017 14:20:06 +0000 (16:20 +0200)
committerGitLab <gitlab@git.dovecot.net>
Sun, 19 Feb 2017 18:42:32 +0000 (20:42 +0200)
These allow determining after mail_*() calls how efficiently they were
performed.

src/lib-storage/index/cydir/cydir-mail.c
src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/raw/raw-mail.c
src/lib-storage/mail-storage.h

index d077c53b82e9e5fc96127a1bc64a71e96e1b13f9..8c8f22a3fb60a3b9b099f2b6eaa183d96711ba08 100644 (file)
@@ -25,6 +25,7 @@ static int cydir_mail_stat(struct mail *mail, struct stat *st_r)
                mail_set_aborted(mail);
                return -1;
        }
+       mail->mail_metadata_accessed = TRUE;
 
        mail->transaction->stats.stat_lookup_count++;
        path = cydir_mail_get_path(mail);
index 717399a120acd2a2660da95acb8c55e7b68322fa..0078637b5edc2903079b890f6e1002613bdee64d 100644 (file)
@@ -106,6 +106,7 @@ int mdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
                mail_set_aborted(_mail);
                return -1;
        }
+       _mail->mail_stream_opened = TRUE;
 
        do {
                if (mail->open_file != NULL) {
index ad5316a60947c0cfdf33fa53f25c32ad396568e8..68344471f2735ee463bb5efcbb08a450f47cb9f7 100644 (file)
@@ -115,6 +115,7 @@ int sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
                mail_set_aborted(_mail);
                return -1;
        }
+       _mail->mail_stream_opened = TRUE;
 
        ret = sdbox_mail_file_set(mail);
        if (ret < 0)
index c6871be1b95cdea8febae6552144be00e7d4c760..2cb91527f0b9c710c940399fe05fe5f8730d00e5 100644 (file)
@@ -214,6 +214,7 @@ imapc_mail_send_fetch(struct mail *_mail, enum mail_fetch_field fields,
 
        if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
                return -1;
+       _mail->mail_stream_opened = TRUE;
 
        /* drop any fields that we may already be fetching currently */
        fields &= ~mail->fetching_fields;
index 4e3395e376652e943fc0cc67a156f91c35890b8c..299f638e50de95ace990c725d20392cadcbee291 100644 (file)
@@ -1219,6 +1219,7 @@ int index_mail_init_stream(struct index_mail *mail,
                        _mail->box->vname, _mail->uid,
                        mail->mail.get_stream_reason);
        }
+       _mail->mail_stream_opened = TRUE;
 
        if (!data->initialized_wrapper_stream &&
            _mail->transaction->stats_track) {
@@ -1639,6 +1640,8 @@ static void index_mail_reset_data(struct index_mail *mail)
        mail->mail.mail.has_nuls = FALSE;
        mail->mail.mail.has_no_nuls = FALSE;
        mail->mail.mail.saving = FALSE;
+       mail->mail.mail.mail_stream_opened = FALSE;
+       mail->mail.mail.mail_metadata_accessed = FALSE;
 }
 
 void index_mail_close(struct mail *_mail)
index 94a5cf52d35f797984a526c3d85c2205fe9c3841..836c4107687ed09adb425363cc1d5167705b4a04 100644 (file)
@@ -112,6 +112,7 @@ static int maildir_mail_stat(struct mail *mail, struct stat *st_r)
                mail_set_aborted(mail);
                return -1;
        }
+       mail->mail_metadata_accessed = TRUE;
 
        if (imail->data.access_part != 0 &&
            imail->data.stream == NULL) {
index d60e0ff9ad6e5838b9be7689b9ecc5037a5f486c..0baa65fa146c55d5ed3f5b8c7bceaa8c885d70f5 100644 (file)
@@ -47,6 +47,7 @@ static int mbox_mail_seek(struct index_mail *mail)
                mail_set_aborted(_mail);
                return -1;
        }
+       _mail->mail_stream_opened = TRUE;
 
        if (mbox->mbox_stream != NULL &&
            istream_raw_mbox_is_corrupted(mbox->mbox_stream)) {
index d179c2cae10523c6cd07daa55758d1349da182a5..9f7c19054ad07b89eb8c3d046eb45c663d96aa3a 100644 (file)
@@ -18,6 +18,7 @@ static int raw_mail_stat(struct mail *mail)
                mail_set_aborted(mail);
                return -1;
        }
+       mail->mail_metadata_accessed = TRUE;
 
        mail->transaction->stats.fstat_lookup_count++;
        if (i_stream_stat(mail->box->input, TRUE, &st) < 0) {
index 54cd37c9815f41a1bc42774261630d340cd89619..514df21d2022e592a449bc234f6d4738288dc498 100644 (file)
@@ -383,6 +383,16 @@ struct mail {
        bool has_nuls:1; /* message data is known to contain NULs */
        bool has_no_nuls:1; /* -''- known to not contain NULs */
 
+       /* Mail's header/body stream was opened within this request.
+          If lookup_abort!=MAIL_LOOKUP_ABORT_NEVER, this can't become TRUE. */
+       bool mail_stream_opened:1;
+       /* Mail's fast metadata was accessed within this request, e.g. the mail
+          file was stat()ed. If mail_stream_opened==TRUE, this value isn't
+          accurate anymore, because some backends may always set this when
+          stream is opened and some don't. If lookup_abort is
+          MAIL_LOOKUP_ABORT_NOT_IN_CACHE, this can't become TRUE. */
+       bool mail_metadata_accessed:1;
+
        /* If the lookup is aborted, error is set to MAIL_ERROR_NOTPOSSIBLE */
        enum mail_lookup_abort lookup_abort;
 };