Mercurial > dovecot > core-2.2
changeset 18323:f8f57dde247d
imapc: Don't flush prefetch FETCH command before it has mail_prefetch_count number of mails.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 11 Mar 2015 14:39:52 +0200 |
parents | d21f71ab9f28 |
children | f7b3c923cf4d |
files | src/lib-storage/index/imapc/imapc-mail-fetch.c |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Wed Mar 11 14:39:26 2015 +0200 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Wed Mar 11 14:39:52 2015 +0200 @@ -146,7 +146,19 @@ } array_append(&mbox->pending_fetch_request->mails, &mail, 1); - if (mbox->to_pending_fetch_send == NULL) { + if (mbox->to_pending_fetch_send == NULL && + array_count(&mbox->pending_fetch_request->mails) > + mbox->box.storage->set->mail_prefetch_count) { + /* we're now prefetching the maximum number of mails. this + most likely means that we need to flush out the command now + before sending anything else. delay it a little bit though + in case the sending code doesn't actually use + mail_prefetch_count and wants to fetch more. + + note that we don't want to add this timeout too early, + because we want to optimize the maximum number of messages + placed into a single FETCH. even without timeout the command + gets flushed by imapc_mail_fetch() call. */ mbox->to_pending_fetch_send = timeout_add_short(0, imapc_mail_fetch_flush, mbox); } @@ -397,7 +409,8 @@ imapc_command_send(cmd, str_c(mbox->pending_fetch_cmd)); mbox->pending_fetch_request = NULL; - timeout_remove(&mbox->to_pending_fetch_send); + if (mbox->to_pending_fetch_send != NULL) + timeout_remove(&mbox->to_pending_fetch_send); str_truncate(mbox->pending_fetch_cmd, 0); }