Mercurial > dovecot > original-hg > dovecot-1.2
diff src/lib-storage/index/shared/shared-storage.c @ 8448:4cf249042df6 HEAD
When autocreating a new shared namespace, drop existing namespaces where we haven't seen any mailboxes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 19 Nov 2008 18:57:43 +0200 |
parents | 1c13cf0f8bb5 |
children | f5554ae61732 |
line wrap: on
line diff
--- a/src/lib-storage/index/shared/shared-storage.c Wed Nov 19 18:46:25 2008 +0200 +++ b/src/lib-storage/index/shared/shared-storage.c Wed Nov 19 18:57:43 2008 +0200 @@ -163,6 +163,20 @@ str_append(location, PKG_RUNDIR"/user-not-found"); } +static void drop_unusable_shared_namespaces(struct mail_user *user) +{ +#define NS_UNUSABLE_FLAGS (NAMESPACE_FLAG_AUTOCREATED | ) + struct mail_namespace *ns, *next; + + for (ns = user->namespaces; ns != NULL; ns = next) { + next = ns->next; + + if ((ns->flags & NAMESPACE_FLAG_USABLE) == 0 && + (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0) + mail_namespace_destroy(ns); + } +} + int shared_storage_get_namespace(struct mail_storage *_storage, const char **_name, struct mail_namespace **ns_r) @@ -284,8 +298,7 @@ ns->prefix, error); return -1; } - /* FIXME: we could remove namespaces here that don't have usable - mailboxes. otherwise the memory usage could just keep growing. */ + drop_unusable_shared_namespaces(user); mail_user_add_namespace(user, ns); *_name = mail_namespace_fix_sep(ns, name); @@ -325,6 +338,8 @@ mailbox_open(ns->storage, name, NULL, flags); if (box == NULL) shared_mailbox_copy_error(storage, ns); + else + ns->flags |= NAMESPACE_FLAG_USABLE; return box; }