Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8981:5611bba3548b HEAD
Added struct mail.lookup_abort, which can be used to abort lookups that can't be done using cache.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 28 Apr 2009 17:20:19 -0400 |
parents | c8de2237478f |
children | 947fab5a8992 |
files | src/lib-storage/index/cydir/cydir-mail.c src/lib-storage/index/dbox/dbox-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-private.h src/lib-storage/mail-storage.h src/lib-storage/mail.c |
diffstat | 8 files changed, 38 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/cydir/cydir-mail.c Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/index/cydir/cydir-mail.c Tue Apr 28 17:20:19 2009 -0400 @@ -22,6 +22,9 @@ { const char *path; + if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) + return mail_set_aborted(mail); + path = cydir_mail_get_path(mail); if (stat(path, st_r) < 0) { if (errno == ENOENT)
--- a/src/lib-storage/index/dbox/dbox-mail.c Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/index/dbox/dbox-mail.c Tue Apr 28 17:20:19 2009 -0400 @@ -67,10 +67,14 @@ static int dbox_mail_metadata_seek(struct dbox_mail *mail, struct dbox_file **file_r) { + struct mail *_mail = &mail->imail.mail.mail; uoff_t offset; bool expunged; int ret; + if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) + return mail_set_aborted(_mail); + if (dbox_mail_lookup(mail, &offset, file_r) < 0) return -1; @@ -82,7 +86,7 @@ return -1; } if (expunged) { - mail_set_expunged(&mail->imail.mail.mail); + mail_set_expunged(_mail); return -1; } return 0;
--- a/src/lib-storage/index/maildir/maildir-mail.c Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/index/maildir/maildir-mail.c Tue Apr 28 17:20:19 2009 -0400 @@ -73,6 +73,9 @@ const char *path; int fd, ret; + if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) + return mail_set_aborted(mail); + if (data->access_part != 0 && data->stream == NULL) { /* we're going to open the mail anyway */ struct istream *input;
--- a/src/lib-storage/index/mbox/mbox-mail.c Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/index/mbox/mbox-mail.c Tue Apr 28 17:20:19 2009 -0400 @@ -41,6 +41,9 @@ if (mail->mail.mail.expunged || mbox->syncing) return -1; + if (mail->mail.mail.lookup_abort != MAIL_LOOKUP_ABORT_NEVER) + return mail_set_aborted(&mail->mail.mail); + if (mbox->mbox_stream != NULL && istream_raw_mbox_is_corrupted(mbox->mbox_stream)) { /* clear the corruption by forcing a full resync */
--- a/src/lib-storage/index/raw/raw-mail.c Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/index/raw/raw-mail.c Tue Apr 28 17:20:19 2009 -0400 @@ -14,6 +14,9 @@ struct raw_mailbox *mbox = (struct raw_mailbox *)mail->box; const struct stat *st; + if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) + return mail_set_aborted(mail); + st = i_stream_stat(mbox->input, TRUE); if (st == NULL) { mail_storage_set_critical(mail->box->storage,
--- a/src/lib-storage/mail-storage-private.h Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/mail-storage-private.h Tue Apr 28 17:20:19 2009 -0400 @@ -376,6 +376,7 @@ bool mail_storage_set_error_from_errno(struct mail_storage *storage); const char *mail_generate_guid_string(void); +int mail_set_aborted(struct mail *mail); void mail_set_expunged(struct mail *mail); void mailbox_set_deleted(struct mailbox *box);
--- a/src/lib-storage/mail-storage.h Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/mail-storage.h Tue Apr 28 17:20:19 2009 -0400 @@ -213,6 +213,15 @@ enum mailbox_sync_type type; }; +enum mail_lookup_abort { + /* Perform everything no matter what it takes */ + MAIL_LOOKUP_ABORT_NEVER = 0, + /* Abort if the operation would require reading message header/body */ + MAIL_LOOKUP_ABORT_READ_MAIL, + /* Abort if the operation can't be done fully using cache file */ + MAIL_LOOKUP_ABORT_NOT_IN_CACHE +}; + struct mail { /* always set */ struct mailbox *box; @@ -222,6 +231,8 @@ unsigned int expunged:1; unsigned int has_nuls:1; /* message data is known to contain NULs */ unsigned int has_no_nuls:1; /* -''- known to not contain NULs */ + + enum mail_lookup_abort lookup_abort; }; struct mail_storage_callbacks {
--- a/src/lib-storage/mail.c Thu Apr 23 12:01:40 2009 -0400 +++ b/src/lib-storage/mail.c Tue Apr 28 17:20:19 2009 -0400 @@ -151,11 +151,20 @@ return p->v.get_header_stream(mail, headers, stream_r); } +int mail_set_aborted(struct mail *mail) +{ + mail_storage_set_error(mail->box->storage, MAIL_ERROR_NOTPOSSIBLE, + "Mail field not cached"); + return -1; +} + int mail_get_stream(struct mail *mail, struct message_size *hdr_size, struct message_size *body_size, struct istream **stream_r) { struct mail_private *p = (struct mail_private *)mail; + if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) + return mail_set_aborted(mail); return p->v.get_stream(mail, hdr_size, body_size, stream_r); }