From: Timo Sirainen Date: Mon, 29 Nov 2021 14:43:29 +0000 (+0100) Subject: lib-storage: Make sure mail event is created before accessing streams or metadata X-Git-Tag: 2.3.18~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a24e4a14f92c0767f352867a1e59b56a57c6ca94;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Make sure mail event is created before accessing streams or metadata This is in preparation for the next commit which delays the mail event creation. The event duration behaves better if the event is created before any potentially slow access is done. --- diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index a809b44ad3..f5f569c36e 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -814,6 +814,7 @@ void mail_set_mail_cache_corrupted(struct mail *mail, const char *fmt, ...) /* Indicate mail being expunged by autoexpunge */ void mail_autoexpunge(struct mail *mail); +void mail_event_create(struct mail *mail); /* Returns TRUE if everything should already be in memory after this call or if prefetching is not supported, i.e. the caller shouldn't do more prefetching before this message is handled. */ diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index 720349fc8e..366670330a 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -99,6 +99,13 @@ void mail_add_temp_wanted_fields(struct mail *mail, p->v.add_temp_wanted_fields(mail, fields, headers); } +void mail_event_create(struct mail *mail) +{ + struct mail_private *p = (struct mail_private *)mail; + + i_assert(p->_event != NULL); +} + struct event *mail_event(struct mail *mail) { struct mail_private *p = (struct mail_private *)mail; @@ -653,6 +660,7 @@ bool mail_stream_access_start(struct mail *mail) return FALSE; } mail->mail_stream_accessed = TRUE; + mail_event_create(mail); return TRUE; } @@ -663,6 +671,7 @@ bool mail_metadata_access_start(struct mail *mail) return FALSE; } mail->mail_metadata_accessed = TRUE; + mail_event_create(mail); return TRUE; }