dovecot-2.2: virtual plugin: Fixed assert-crash when closing a v...

dovecot at dovecot.org dovecot at dovecot.org
Thu Sep 24 16:08:32 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/4b5b8e6a4a32
changeset: 19214:4b5b8e6a4a32
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Sep 24 19:07:12 2015 +0300
description:
virtual plugin: Fixed assert-crash when closing a virtual mailbox consisting of many real mailboxes.

diffstat:

 src/plugins/virtual/virtual-storage.c |  22 +++++++++++++++++-----
 src/plugins/virtual/virtual-storage.h |   1 +
 2 files changed, 18 insertions(+), 5 deletions(-)

diffs (57 lines):

diff -r 3599f7b9ea09 -r 4b5b8e6a4a32 src/plugins/virtual/virtual-storage.c
--- a/src/plugins/virtual/virtual-storage.c	Thu Sep 24 18:42:58 2015 +0300
+++ b/src/plugins/virtual/virtual-storage.c	Thu Sep 24 19:07:12 2015 +0300
@@ -325,12 +325,15 @@
 void virtual_backend_box_opened(struct virtual_mailbox *mbox,
 				struct virtual_backend_box *bbox)
 {
+	i_assert(!bbox->open_tracked);
+
 	/* the backend mailbox was already opened. if we didn't get here
 	   from virtual_backend_box_open() we may need to close a mailbox */
 	while (mbox->backends_open_count > mbox->storage->max_open_mailboxes &&
 	       virtual_backend_box_close_any_except(mbox, bbox))
 		;
 
+	bbox->open_tracked = TRUE;
 	mbox->backends_open_count++;
 	DLLIST2_APPEND_FULL(&mbox->open_backend_boxes_head,
 			    &mbox->open_backend_boxes_tail, bbox,
@@ -367,12 +370,21 @@
 		mail_search_args_deinit(bbox->search_args);
 		bbox->search_args_initialized = FALSE;
 	}
-	i_assert(mbox->backends_open_count > 0);
-	mbox->backends_open_count--;
+	if (bbox->open_tracked) {
+		i_assert(mbox->backends_open_count > 0);
+		mbox->backends_open_count--;
+		bbox->open_tracked = FALSE;
 
-	DLLIST2_REMOVE_FULL(&mbox->open_backend_boxes_head,
-			    &mbox->open_backend_boxes_tail, bbox,
-			    prev_open, next_open);
+		DLLIST2_REMOVE_FULL(&mbox->open_backend_boxes_head,
+				    &mbox->open_backend_boxes_tail, bbox,
+				    prev_open, next_open);
+	} else {
+		/* mailbox can be leaked outside our code via
+		   virtual_get_virtual_backend_boxes() and it could have
+		   been opened there. FIXME: maybe we could hook into the
+		   backend open/close functions to do the tracking and
+		   auto-closing. */
+	}
 	mailbox_close(bbox->box);
 }
 
diff -r 3599f7b9ea09 -r 4b5b8e6a4a32 src/plugins/virtual/virtual-storage.h
--- a/src/plugins/virtual/virtual-storage.h	Thu Sep 24 18:42:58 2015 +0300
+++ b/src/plugins/virtual/virtual-storage.h	Thu Sep 24 19:07:12 2015 +0300
@@ -97,6 +97,7 @@
 	struct imap_match_glob *glob;
 	struct mail_namespace *ns;
 
+	unsigned int open_tracked:1;
 	unsigned int open_failed:1;
 	unsigned int sync_seen:1;
 	unsigned int wildcard:1;


More information about the dovecot-cvs mailing list