dovecot-2.0: maildir: Fixed a race condition in getting a new me...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 23 20:18:54 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/9d9cb38f1b5d
changeset: 12162:9d9cb38f1b5d
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 23 18:18:51 2010 +0100
description:
maildir: Fixed a race condition in getting a new message's GUID.
diffstat:
src/lib-storage/index/maildir/maildir-mail.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r 24b84a62d8fe -r 9d9cb38f1b5d src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Thu Sep 23 18:02:20 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-mail.c Thu Sep 23 18:18:51 2010 +0100
@@ -469,11 +469,17 @@
{
struct index_mail *mail = (struct index_mail *)_mail;
struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
- const char *path, *fname, *end, *guid, *uidl;
+ const char *path, *fname = NULL, *end, *guid, *uidl;
switch (field) {
case MAIL_FETCH_GUID:
/* use GUID from uidlist if it exists */
+ i_assert(!_mail->saving);
+
+ /* first make sure that we have a refreshed uidlist */
+ if (maildir_mail_get_fname(mbox, _mail, &fname) <= 0)
+ return -1;
+
guid = maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid,
MAILDIR_UIDLIST_REC_EXT_GUID);
if (guid != NULL) {
@@ -487,7 +493,10 @@
*value_r = mail->data.guid;
return 0;
}
- if (!_mail->saving) {
+ if (fname != NULL) {
+ /* we came here from MAIL_FETCH_GUID,
+ avoid a second lookup */
+ } else if (!_mail->saving) {
if (maildir_mail_get_fname(mbox, _mail, &fname) <= 0)
return -1;
} else {
More information about the dovecot-cvs
mailing list