[dovecot-cvs] dovecot/src/lib-storage mail-storage-private.h, 1.37, 1.38 mail-storage.c, 1.63, 1.64 mail-storage.h, 1.118, 1.119 mailbox-list-private.h, 1.1, 1.2 mailbox-list.c, 1.2, 1.3 mailbox-list.h, 1.1, 1.2 mailbox-tree.c, 1.2, 1.3

tss at dovecot.org tss at dovecot.org
Sat Nov 25 22:17:44 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-storage
In directory talvi:/tmp/cvs-serv28938/lib-storage

Modified Files:
	mail-storage-private.h mail-storage.c mail-storage.h 
	mailbox-list-private.h mailbox-list.c mailbox-list.h 
	mailbox-tree.c 
Log Message:
Mailbox list indexing and related changes. Currently works only with
maildir and mmap_disable=no. This allows doing STATUS to synced mailboxes
without opening their index files at all.



Index: mail-storage-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- mail-storage-private.h	18 Nov 2006 14:05:46 -0000	1.37
+++ mail-storage-private.h	25 Nov 2006 22:17:41 -0000	1.38
@@ -8,6 +8,8 @@
 #define MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND "Mailbox doesn't exist: %s"
 #define MAIL_STORAGE_ERR_NO_PERMISSION "Permission denied"
 
+/* Called after mail storage has been created */
+extern void (*hook_mail_storage_created)(struct mail_storage *storage);
 /* Called after mailbox has been opened */
 extern void (*hook_mailbox_opened)(struct mailbox *box);
 
@@ -93,6 +95,7 @@
 	int (*sync_next)(struct mailbox_sync_context *ctx,
 			 struct mailbox_sync_rec *sync_rec_r);
 	int (*sync_deinit)(struct mailbox_sync_context *ctx,
+			   enum mailbox_status_items status_items,
 			   struct mailbox_status *status_r);
 
 	void (*notify_changes)(struct mailbox *box, unsigned int min_interval,
@@ -162,6 +165,10 @@
 
 	/* Module-specific contexts. See mail_storage_module_id. */
 	ARRAY_DEFINE(module_contexts, void);
+
+	/* When FAST open flag is used, the mailbox isn't actually opened until
+	   it's synced for the first time. */
+	unsigned int opened:1;
 };
 
 struct mail_vfuncs {

Index: mail-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- mail-storage.c	18 Nov 2006 11:53:49 -0000	1.63
+++ mail-storage.c	25 Nov 2006 22:17:41 -0000	1.64
@@ -19,6 +19,7 @@
 unsigned int mail_storage_module_id = 0;
 unsigned int mail_storage_mail_index_module_id = 0;
 
+void (*hook_mail_storage_created)(struct mail_storage *storage);
 void (*hook_mailbox_opened)(struct mailbox *box) = NULL;
 
 static ARRAY_DEFINE(storages, struct mail_storage *);
@@ -119,10 +120,13 @@
 	struct mail_storage *storage;
 
 	storage = mail_storage_find(driver);
-	if (storage != NULL)
-		return storage->v.create(data, user, flags, lock_method);
-	else
+	if (storage == NULL)
 		return NULL;
+
+	storage = storage->v.create(data, user, flags, lock_method);
+	if (hook_mail_storage_created != NULL && storage != NULL)
+		hook_mail_storage_created(storage);
+	return storage;
 }
 
 static struct mail_storage *
@@ -136,8 +140,11 @@
 	classes = array_get(&storages, &count);
 	for (i = 0; i < count; i++) {
 		storage = classes[i]->v.create(NULL, user, flags, lock_method);
-		if (storage != NULL)
+		if (storage != NULL) {
+			if (hook_mail_storage_created != NULL)
+				hook_mail_storage_created(storage);
 			return storage;
+		}
 	}
 	return NULL;
 }
@@ -192,6 +199,8 @@
 		}
 	}
 
+	if (hook_mail_storage_created != NULL && storage != NULL)
+		hook_mail_storage_created(storage);
 	return storage;
 }
 
@@ -458,12 +467,13 @@
 }
 
 int mailbox_sync_deinit(struct mailbox_sync_context **_ctx,
+			enum mailbox_status_items status_items,
 			struct mailbox_status *status_r)
 {
 	struct mailbox_sync_context *ctx = *_ctx;
 
 	*_ctx = NULL;
-	return ctx->box->v.sync_deinit(ctx, status_r);
+	return ctx->box->v.sync_deinit(ctx, status_items, status_r);
 }
 
 void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,

Index: mail-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- mail-storage.h	16 Nov 2006 00:16:32 -0000	1.118
+++ mail-storage.h	25 Nov 2006 22:17:41 -0000	1.119
@@ -303,6 +303,7 @@
 int mailbox_sync_next(struct mailbox_sync_context *ctx,
 		      struct mailbox_sync_rec *sync_rec_r);
 int mailbox_sync_deinit(struct mailbox_sync_context **ctx,
+			enum mailbox_status_items status_items,
 			struct mailbox_status *status_r);
 
 /* Call given callback function when something changes in the mailbox.

Index: mailbox-list-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mailbox-list-private.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mailbox-list-private.h	16 Nov 2006 00:16:32 -0000	1.1
+++ mailbox-list-private.h	25 Nov 2006 22:17:41 -0000	1.2
@@ -22,10 +22,11 @@
 				       enum mailbox_name_status *status);
 
 	const char *(*get_temp_prefix)(struct mailbox_list *list);
+	const char *(*join_refmask)(struct mailbox_list *list,
+				    const char *ref, const char *mask);
 
 	struct mailbox_list_iterate_context *
-		(*iter_init)(struct mailbox_list *list,
-			     const char *ref, const char *mask,
+		(*iter_init)(struct mailbox_list *list, const char *mask,
 			     enum mailbox_list_iter_flags flags);
 	struct mailbox_info *
 		(*iter_next)(struct mailbox_list_iterate_context *ctx);
@@ -75,5 +76,6 @@
 void mailbox_list_set_error(struct mailbox_list *list, const char *error);
 void mailbox_list_set_critical(struct mailbox_list *list, const char *fmt, ...)
 	__attr_format__(2, 3);
+void mailbox_list_set_internal_error(struct mailbox_list *list);
 
 #endif

Index: mailbox-list.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mailbox-list.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mailbox-list.c	18 Nov 2006 11:53:49 -0000	1.2
+++ mailbox-list.c	25 Nov 2006 22:17:41 -0000	1.3
@@ -111,6 +111,9 @@
 		p_strdup(list->pool, set->subscription_fname);
 	list->set.maildir_name = p_strdup(list->pool, set->maildir_name);
 
+	list->set.mail_storage_flags = set->mail_storage_flags;
+	list->set.mail_storage_lock_method = set->mail_storage_lock_method;
+
 	if ((flags & MAILBOX_LIST_FLAG_DEBUG) != 0) {
 		i_info("%s: root=%s, index=%s, control=%s, inbox=%s",
 		       driver, list->set.root_dir,
@@ -126,6 +129,9 @@
 	if (hook_mailbox_list_created != NULL)
 		hook_mailbox_list_created(list);
 
+	list->set.mail_storage_flags = NULL;
+	list->set.mail_storage_lock_method = NULL;
+
 	*list_r = list;
 	return 0;
 }
@@ -175,6 +181,12 @@
 	return list->v.get_temp_prefix(list);
 }
 
+const char *mailbox_list_join_refmask(struct mailbox_list *list,
+				      const char *ref, const char *mask)
+{
+	return list->v.join_refmask(list, ref, mask);
+}
+
 int mailbox_list_get_mailbox_name_status(struct mailbox_list *list,
 					 const char *name,
 					 enum mailbox_name_status *status)
@@ -183,11 +195,10 @@
 }
 
 struct mailbox_list_iterate_context *
-mailbox_list_iter_init(struct mailbox_list *list,
-		       const char *ref, const char *mask,
+mailbox_list_iter_init(struct mailbox_list *list, const char *mask,
 		       enum mailbox_list_iter_flags flags)
 {
-	return list->v.iter_init(list, ref, mask, flags);
+	return list->v.iter_init(list, mask, flags);
 }
 
 struct mailbox_info *
@@ -284,7 +295,7 @@
 	list->temporary_error = FALSE;
 }
 
-static void mailbox_list_set_internal_error(struct mailbox_list *list)
+void mailbox_list_set_internal_error(struct mailbox_list *list)
 {
 	struct tm *tm;
 	char str[256];

Index: mailbox-list.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mailbox-list.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mailbox-list.h	16 Nov 2006 00:16:32 -0000	1.1
+++ mailbox-list.h	25 Nov 2006 22:17:41 -0000	1.2
@@ -16,14 +16,11 @@
 enum mailbox_info_flags {
 	MAILBOX_NOSELECT	= 0x001,
 	MAILBOX_NONEXISTENT	= 0x002,
-	MAILBOX_PLACEHOLDER	= 0x004,
-	MAILBOX_CHILDREN	= 0x008,
-	MAILBOX_NOCHILDREN	= 0x010,
-	MAILBOX_NOINFERIORS	= 0x020,
-	MAILBOX_MARKED		= 0x040,
-	MAILBOX_UNMARKED	= 0x080,
-
-	MAILBOX_READONLY	= 0x100
+	MAILBOX_CHILDREN	= 0x004,
+	MAILBOX_NOCHILDREN	= 0x008,
+	MAILBOX_NOINFERIORS	= 0x010,
+	MAILBOX_MARKED		= 0x020,
+	MAILBOX_UNMARKED	= 0x040
 };
 
 enum mailbox_name_status {
@@ -81,6 +78,11 @@
 	   If mailbox_name is "Maildir", you have a non-selectable mailbox
 	   "mail" and a selectable mailbox "mail/foo". */
 	const char *maildir_name;
+
+	/* If mailbox index is used, use these settings for it
+	   (pointers, so they're set to NULL after init is finished): */
+	const enum mail_storage_flags *mail_storage_flags;
+	const enum mail_storage_lock_method *mail_storage_lock_method;
 };
 
 struct mailbox_info {
@@ -135,11 +137,14 @@
    with the namespace. */
 const char *mailbox_list_get_temp_prefix(struct mailbox_list *list);
 
+/* Returns a single mask from given reference and mask. */
+const char *mailbox_list_join_refmask(struct mailbox_list *list,
+				      const char *ref, const char *mask);
+
 /* Initialize new mailbox list request. mask may contain '%' and '*'
    wildcards as defined by RFC-3501. */
 struct mailbox_list_iterate_context *
-mailbox_list_iter_init(struct mailbox_list *list,
-		       const char *ref, const char *mask,
+mailbox_list_iter_init(struct mailbox_list *list, const char *mask,
 		       enum mailbox_list_iter_flags flags);
 /* Get next mailbox. Returns the mailbox name */
 struct mailbox_info *

Index: mailbox-tree.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mailbox-tree.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mailbox-tree.c	13 Jan 2006 20:26:24 -0000	1.2
+++ mailbox-tree.c	25 Nov 2006 22:17:41 -0000	1.3
@@ -75,9 +75,10 @@
 			*node = p_new(ctx->pool, struct mailbox_node, 1);
 			(*node)->name = p_strdup(ctx->pool, name);
 
-			if (*path != '\0')
-				(*node)->flags = MAILBOX_PLACEHOLDER;
-			else {
+			if (*path != '\0') {
+				(*node)->flags = MAILBOX_NONEXISTENT |
+					MAILBOX_CHILDREN;
+			} else {
 				if (created != NULL)
 					*created = TRUE;
 			}



More information about the dovecot-cvs mailing list