[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.173, 1.174

tss at dovecot.org tss at dovecot.org
Fri Mar 30 15:58:55 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv18585/index/mbox

Modified Files:
	mbox-storage.c 
Log Message:
Added virtual mail_storage.alloc() function and changed create() to work
differently.



Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- mbox-storage.c	30 Mar 2007 12:44:07 -0000	1.173
+++ mbox-storage.c	30 Mar 2007 12:58:52 -0000	1.174
@@ -400,30 +400,38 @@
 	return path;
 }
 
-static struct mail_storage *
-mbox_create(const char *data, const char *user, enum mail_storage_flags flags,
-	    enum file_lock_method lock_method)
+static struct mail_storage *mbox_alloc(void)
 {
 	struct mbox_storage *storage;
+	pool_t pool;
+
+	pool = pool_alloconly_create("mbox storage", 512+256);
+	storage = p_new(pool, struct mbox_storage, 1);
+	storage->storage = mbox_storage;
+	storage->storage.pool = pool;
+
+	return &storage->storage;
+}
+
+static int
+mbox_create(struct mail_storage *_storage, const char *data, const char *user,
+	    enum mail_storage_flags flags, enum file_lock_method lock_method)
+{
+	struct mbox_storage *storage = (struct mbox_storage *)_storage;
 	struct mailbox_list_settings list_set;
 	struct mailbox_list *list;
 	const char *layout, *error;
-	pool_t pool;
 
 	if (mbox_get_list_settings(&list_set, data, flags, &layout) < 0)
-		return NULL;
+		return -1;
 	list_set.mail_storage_flags = &flags;
 	list_set.lock_method = &lock_method;
 
-	pool = pool_alloconly_create("storage", 512+256);
-	storage = p_new(pool, struct mbox_storage, 1);
-
 	if (mailbox_list_init(layout, &list_set,
 			      mail_storage_get_list_flags(flags),
 			      &list, &error) < 0) {
 		i_error("mbox %s: %s", layout, error);
-		pool_unref(pool);
-		return NULL;
+		return -1;
 	}
 	storage->list_module_ctx.super = list->v;
 	if (strcmp(layout, "fs") == 0 && *list_set.maildir_name == '\0') {
@@ -436,11 +444,9 @@
 	MODULE_CONTEXT_SET_FULL(list, mbox_mailbox_list_module,
 				storage, &storage->list_module_ctx);
 
-	storage->storage = mbox_storage;
-	storage->storage.pool = pool;
-	storage->storage.user = p_strdup(pool, user);
-	index_storage_init(&storage->storage, list, flags, lock_method);
-	return &storage->storage;
+	_storage->user = p_strdup(_storage->pool, user);
+	index_storage_init(_storage, list, flags, lock_method);
+	return 0;
 }
 
 static void mbox_free(struct mail_storage *storage)
@@ -528,8 +534,9 @@
 }
 
 static struct mbox_mailbox *
-mbox_alloc(struct mbox_storage *storage, struct mail_index *index,
-	   const char *name, const char *path, enum mailbox_open_flags flags)
+mbox_alloc_mailbox(struct mbox_storage *storage, struct mail_index *index,
+		   const char *name, const char *path,
+		   enum mailbox_open_flags flags)
 {
 	struct mbox_mailbox *mbox;
 	pool_t pool;
@@ -602,7 +609,7 @@
 	}
 
 	index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX);
-	mbox = mbox_alloc(storage, index, name, path, flags);
+	mbox = mbox_alloc_mailbox(storage, index, name, path, flags);
 
 	if (access(path, R_OK|W_OK) < 0) {
 		if (errno < EACCES)
@@ -641,7 +648,7 @@
 	}
 
 	index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX);
-	mbox = mbox_alloc(storage, index, name, path, flags);
+	mbox = mbox_alloc_mailbox(storage, index, name, path, flags);
 	if (mbox == NULL)
 		return NULL;
 
@@ -1008,6 +1015,7 @@
 	{
 		mbox_class_init,
 		mbox_class_deinit,
+		mbox_alloc,
 		mbox_create,
 		mbox_free,
 		mbox_autodetect,



More information about the dovecot-cvs mailing list