Mercurial > dovecot > core-2.2
changeset 12878:194855240d31
imapc: Stop FETCH wait after untagged reply is received, don't wait for tagged reply.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 04 Apr 2011 13:42:23 +0300 |
parents | 51ef5ffea07f |
children | 939e0fccd517 |
files | src/lib-storage/index/imapc/imapc-mail-fetch.c src/lib-storage/index/imapc/imapc-mail.c |
diffstat | 2 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Mon Apr 04 13:07:19 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Mon Apr 04 13:42:23 2011 +0300 @@ -112,6 +112,24 @@ return !mail->imail.data.prefetch_sent; } +static bool +imapc_mail_have_fields(struct imapc_mail *imail, enum mail_fetch_field fields) +{ + if ((fields & MAIL_FETCH_RECEIVED_DATE) != 0) { + if (imail->imail.data.received_date == (time_t)-1) + return FALSE; + fields &= ~MAIL_FETCH_RECEIVED_DATE; + } + if ((fields & (MAIL_FETCH_STREAM_HEADER | + MAIL_FETCH_STREAM_BODY)) != 0) { + if (imail->imail.data.stream == NULL) + return FALSE; + fields &= ~(MAIL_FETCH_STREAM_HEADER | MAIL_FETCH_STREAM_BODY); + } + i_assert(fields == 0); + return TRUE; +} + int imapc_mail_fetch(struct mail *_mail, enum mail_fetch_field fields) { struct imapc_mail *imail = (struct imapc_mail *)_mail; @@ -125,7 +143,10 @@ if (ret < 0) return -1; - while (imail->fetch_count > 0) + /* we'll continue waiting until we've got all the fields we wanted, + or until all FETCH replies have been received (i.e. some FETCHes + failed) */ + while (!imapc_mail_have_fields(imail, fields) && imail->fetch_count > 0) imapc_client_run(storage->client); return 0; }
--- a/src/lib-storage/index/imapc/imapc-mail.c Mon Apr 04 13:07:19 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Mon Apr 04 13:42:23 2011 +0300 @@ -179,8 +179,19 @@ (void)imapc_mail_prefetch(_mail); } +static void imapc_mail_close(struct mail *_mail) +{ + struct imapc_mail *imail = (struct imapc_mail *)_mail; + struct imapc_storage *storage = + (struct imapc_storage *)_mail->box->storage; + + while (imail->fetch_count > 0) + imapc_client_run(storage->client); + index_mail_close(_mail); +} + struct mail_vfuncs imapc_mail_vfuncs = { - index_mail_close, + imapc_mail_close, imapc_mail_free, imapc_mail_set_seq, index_mail_set_uid,