From: Timo Sirainen Date: Wed, 11 Mar 2015 12:39:52 +0000 (+0200) Subject: imapc: Don't flush prefetch FETCH command before it has mail_prefetch_count number... X-Git-Tag: 2.2.16~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b43d7e2b753d69fa6eafcf647d75e6af1dcc0fc8;p=thirdparty%2Fdovecot%2Fcore.git imapc: Don't flush prefetch FETCH command before it has mail_prefetch_count number of mails. --- diff --git a/src/lib-storage/index/imapc/imapc-mail-fetch.c b/src/lib-storage/index/imapc/imapc-mail-fetch.c index b54ad3d325..c104fe9c1c 100644 --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c @@ -146,7 +146,19 @@ imapc_mail_delayed_send_or_merge(struct imapc_mail *mail, string_t *str) } 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 @@ void imapc_mail_fetch_flush(struct imapc_mailbox *mbox) 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); }