dovecot-2.2: imapc: Make sure we don't flush prefetch FETCH comm...

dovecot at dovecot.org dovecot at dovecot.org
Wed Mar 11 14:40:51 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/d21f71ab9f28
changeset: 18322:d21f71ab9f28
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Mar 11 14:39:26 2015 +0200
description:
imapc: Make sure we don't flush prefetch FETCH command unneededly.

diffstat:

 src/lib-storage/index/imapc/imapc-mail-fetch.c |  10 ++++++++--
 src/lib-storage/index/imapc/imapc-mail.h       |   1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diffs (58 lines):

diff -r 878e9d914339 -r d21f71ab9f28 src/lib-storage/index/imapc/imapc-mail-fetch.c
--- a/src/lib-storage/index/imapc/imapc-mail-fetch.c	Wed Mar 11 13:28:24 2015 +0200
+++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c	Wed Mar 11 14:39:26 2015 +0200
@@ -171,7 +171,7 @@
 	if (headers_have_subset(mail->fetching_headers, headers))
 		headers = NULL;
 	if (fields == 0 && headers == NULL)
-		return 0;
+		return mail->fetch_sent ? 0 : 1;
 
 	if (!_mail->saving) {
 		/* if we already know that the mail is expunged,
@@ -229,6 +229,7 @@
 	pool_ref(mail->imail.mail.pool);
 	mail->fetching_fields |= fields;
 	mail->fetch_count++;
+	mail->fetch_sent = FALSE;
 
 	imapc_mail_delayed_send_or_merge(mail, str);
 	return 1;
@@ -365,7 +366,8 @@
 	/* 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) */
-	imapc_mail_fetch_flush(mbox);
+	if (ret > 0)
+		imapc_mail_fetch_flush(mbox);
 	while (imail->fetch_count > 0 &&
 	       (!imapc_mail_have_fields(imail, fields) ||
 		!imail->header_list_fetched))
@@ -376,12 +378,16 @@
 void imapc_mail_fetch_flush(struct imapc_mailbox *mbox)
 {
 	struct imapc_command *cmd;
+	struct imapc_mail *const *mailp;
 
 	if (mbox->pending_fetch_request == NULL) {
 		i_assert(mbox->to_pending_fetch_send == NULL);
 		return;
 	}
 
+	array_foreach(&mbox->pending_fetch_request->mails, mailp)
+		(*mailp)->fetch_sent = TRUE;
+
 	cmd = imapc_client_mailbox_cmd(mbox->client_box,
 				       imapc_mail_fetch_callback,
 				       mbox->pending_fetch_request);
diff -r 878e9d914339 -r d21f71ab9f28 src/lib-storage/index/imapc/imapc-mail.h
--- a/src/lib-storage/index/imapc/imapc-mail.h	Wed Mar 11 13:28:24 2015 +0200
+++ b/src/lib-storage/index/imapc/imapc-mail.h	Wed Mar 11 14:39:26 2015 +0200
@@ -13,6 +13,7 @@
 	enum mail_fetch_field fetching_fields;
 	const char *const *fetching_headers;
 	unsigned int fetch_count;
+	bool fetch_sent;
 
 	int fd;
 	buffer_t *body;


More information about the dovecot-cvs mailing list