dovecot-2.0: mdbox: Don't crash when trying to rebuild storage a...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 6 12:53:02 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/e3672e7c0f9f
changeset: 10843:e3672e7c0f9f
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 06 12:52:59 2010 +0200
description:
mdbox: Don't crash when trying to rebuild storage at deinit.
diffstat:
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 ++
src/lib-storage/mail-namespace.c | 13 ++++++++-----
src/lib-storage/mail-storage.c | 10 +++++++---
3 files changed, 17 insertions(+), 8 deletions(-)
diffs (65 lines):
diff -r a81aceb9f55b -r e3672e7c0f9f src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sat Mar 06 12:30:53 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sat Mar 06 12:52:59 2010 +0200
@@ -723,6 +723,8 @@
static int rebuild_finish(struct mdbox_storage_rebuild_context *ctx)
{
+ i_assert(ctx->default_list != NULL);
+
if (rebuild_handle_zero_refs(ctx) < 0)
return -1;
rebuild_update_refcounts(ctx);
diff -r a81aceb9f55b -r e3672e7c0f9f src/lib-storage/mail-namespace.c
--- a/src/lib-storage/mail-namespace.c Sat Mar 06 12:30:53 2010 +0200
+++ b/src/lib-storage/mail-namespace.c Sat Mar 06 12:52:59 2010 +0200
@@ -340,14 +340,17 @@
void mail_namespaces_deinit(struct mail_namespace **_namespaces)
{
- struct mail_namespace *ns, *namespaces = *_namespaces;
+ struct mail_namespace *ns, *next;
- *_namespaces = NULL;
- while (namespaces != NULL) {
- ns = namespaces;
- namespaces = namespaces->next;
+ /* update *_namespaces as needed, instead of immediately setting it
+ to NULL. for example mdbox_storage.destroy() wants to go through
+ user's namespaces. */
+ while (*_namespaces != NULL) {
+ ns = *_namespaces;
+ next = ns->next;
mail_namespace_free(ns);
+ *_namespaces = next;
}
}
diff -r a81aceb9f55b -r e3672e7c0f9f src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Sat Mar 06 12:30:53 2010 +0200
+++ b/src/lib-storage/mail-storage.c Sat Mar 06 12:52:59 2010 +0200
@@ -324,16 +324,20 @@
i_assert(storage->refcount > 0);
- *_storage = NULL;
-
- if (--storage->refcount > 0)
+ /* set *_storage=NULL only after calling destroy() callback.
+ for example mdbox wants to access ns->storage */
+ if (--storage->refcount > 0) {
+ *_storage = NULL;
return;
+ }
DLLIST_REMOVE(&storage->user->storages, storage);
if (storage->v.destroy != NULL)
storage->v.destroy(storage);
i_free(storage->error_string);
+
+ *_storage = NULL;
pool_unref(&storage->pool);
mail_index_alloc_cache_destroy_unrefed();
More information about the dovecot-cvs
mailing list