dovecot-2.2: virtual: Fixed assert-crash when opening virtual ma...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Dec 9 13:31:57 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/097a0175a591
changeset: 19499:097a0175a591
user: Timo Sirainen <tss at iki.fi>
date: Wed Dec 09 15:31:37 2015 +0200
description:
virtual: Fixed assert-crash when opening virtual mailbox triggered backend mailbox autocreation.
Fixes assert:
Panic: file virtual-storage.c: line 335 (virtual_mailbox_opened_hook):
assertion failed: (!bbox->open_tracked)
diffstat:
src/plugins/virtual/virtual-plugin.c | 3 +-
src/plugins/virtual/virtual-storage.c | 36 ++++++++++++++++++++++++++++++++++-
src/plugins/virtual/virtual-storage.h | 3 +-
3 files changed, 39 insertions(+), 3 deletions(-)
diffs (84 lines):
diff -r d397b0ad0ac4 -r 097a0175a591 src/plugins/virtual/virtual-plugin.c
--- a/src/plugins/virtual/virtual-plugin.c Wed Dec 09 13:51:35 2015 +0200
+++ b/src/plugins/virtual/virtual-plugin.c Wed Dec 09 15:31:37 2015 +0200
@@ -8,7 +8,8 @@
const char *virtual_plugin_version = DOVECOT_ABI_VERSION;
static struct mail_storage_hooks acl_mail_storage_hooks = {
- .mailbox_opened = virtual_mailbox_opened_hook
+ .mailbox_allocated = virtual_backend_mailbox_allocated,
+ .mailbox_opened = virtual_backend_mailbox_opened
};
void virtual_plugin_init(struct module *module ATTR_UNUSED)
diff -r d397b0ad0ac4 -r 097a0175a591 src/plugins/virtual/virtual-storage.c
--- a/src/plugins/virtual/virtual-storage.c Wed Dec 09 13:51:35 2015 +0200
+++ b/src/plugins/virtual/virtual-storage.c Wed Dec 09 15:31:37 2015 +0200
@@ -22,12 +22,21 @@
#define VIRTUAL_DEFAULT_MAX_OPEN_MAILBOXES 64
+#define VIRTUAL_BACKEND_CONTEXT(obj) \
+ MODULE_CONTEXT(obj, virtual_backend_storage_module)
+
+struct virtual_backend_mailbox {
+ union mailbox_module_context module_ctx;
+};
+
extern struct mail_storage virtual_storage;
extern struct mailbox virtual_mailbox;
extern struct virtual_mailbox_vfuncs virtual_mailbox_vfuncs;
struct virtual_storage_module virtual_storage_module =
MODULE_CONTEXT_INIT(&mail_storage_module_register);
+static MODULE_CONTEXT_DEFINE_INIT(virtual_backend_storage_module,
+ &mail_storage_module_register);
static bool ns_is_visible(struct mail_namespace *ns)
{
@@ -323,7 +332,32 @@
return FALSE;
}
-void virtual_mailbox_opened_hook(struct mailbox *box)
+static void virtual_backend_mailbox_close(struct mailbox *box)
+{
+ struct virtual_backend_box *bbox = VIRTUAL_CONTEXT(box);
+ struct virtual_backend_mailbox *vbox = VIRTUAL_BACKEND_CONTEXT(box);
+
+ if (bbox != NULL && bbox->open_tracked) {
+ /* we could have gotten here from e.g. mailbox_autocreate()
+ without going through virtual_mailbox_close() */
+ virtual_backend_box_close(bbox->virtual_mbox, bbox);
+ }
+ vbox->module_ctx.super.close(box);
+}
+
+void virtual_backend_mailbox_allocated(struct mailbox *box)
+{
+ struct mailbox_vfuncs *v = box->vlast;
+ struct virtual_backend_mailbox *vbox;
+
+ vbox = p_new(box->pool, struct virtual_backend_mailbox, 1);
+ vbox->module_ctx.super = *v;
+ box->vlast = &vbox->module_ctx.super;
+ v->close = virtual_backend_mailbox_close;
+ MODULE_CONTEXT_SET(box, virtual_backend_storage_module, vbox);
+}
+
+void virtual_backend_mailbox_opened(struct mailbox *box)
{
struct virtual_backend_box *bbox = VIRTUAL_CONTEXT(box);
struct virtual_mailbox *mbox;
diff -r d397b0ad0ac4 -r 097a0175a591 src/plugins/virtual/virtual-storage.h
--- a/src/plugins/virtual/virtual-storage.h Wed Dec 09 13:51:35 2015 +0200
+++ b/src/plugins/virtual/virtual-storage.h Wed Dec 09 15:31:37 2015 +0200
@@ -225,6 +225,7 @@
void virtual_box_copy_error(struct mailbox *dest, struct mailbox *src);
-void virtual_mailbox_opened_hook(struct mailbox *box);
+void virtual_backend_mailbox_allocated(struct mailbox *box);
+void virtual_backend_mailbox_opened(struct mailbox *box);
#endif
More information about the dovecot-cvs
mailing list