changeset 20013:b651598623f9

imapc: If root separator lookup fails, fail all further lookups. We already returned a potentially wrong separator (since there's no way to return error), so we don't want to continue and possibly make things worse.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 06 Apr 2016 14:44:00 +0300
parents 7070360c2d95
children b924e2e16783
files src/lib-storage/index/imapc/imapc-list.c src/lib-storage/index/imapc/imapc-list.h
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-list.c	Wed Apr 06 14:43:02 2016 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.c	Wed Apr 06 14:44:00 2016 +0300
@@ -324,9 +324,11 @@
 	struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list;
 	char sep;
 
-	if (imapc_list_try_get_root_sep(list, &sep) < 0) {
-		/* we can't really fail here. just return a common separator
-		   and keep failing all list commands until it succeeds. */
+	if (list->root_sep_lookup_failed ||
+	    imapc_list_try_get_root_sep(list, &sep) < 0) {
+		/* we can't really return a failure here. just return a common
+		   separator and fail all the future list operations. */
+		list->root_sep_lookup_failed = TRUE;
 		return '/';
 	}
 	return sep;
@@ -546,6 +548,10 @@
 	struct mailbox_node *node;
 	const char *pattern;
 
+	if (list->root_sep_lookup_failed) {
+		mailbox_list_set_internal_error(&list->list);
+		return -1;
+	}
 	if (list->refreshed_mailboxes)
 		return 0;
 
@@ -774,6 +780,11 @@
 
 	i_assert(src_list->tmp_subscriptions == NULL);
 
+	if (src_list->root_sep_lookup_failed) {
+		mailbox_list_set_internal_error(_src_list);
+		return -1;
+	}
+
 	if (src_list->refreshed_subscriptions) {
 		if (dest_list->subscriptions == NULL)
 			dest_list->subscriptions = mailbox_tree_init(dest_sep);
--- a/src/lib-storage/index/imapc/imapc-list.h	Wed Apr 06 14:43:02 2016 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.h	Wed Apr 06 14:44:00 2016 +0300
@@ -30,6 +30,7 @@
 	unsigned int refreshed_mailboxes_recently:1;
 	unsigned int index_list_failed:1;
 	unsigned int root_sep_pending:1;
+	unsigned int root_sep_lookup_failed:1;
 };
 
 int imapc_list_get_mailbox_flags(struct mailbox_list *list, const char *name,