[dovecot-cvs] dovecot/src/lib-storage/index index-storage.c, 1.86, 1.87 index-storage.h, 1.103, 1.104 index-transaction.c, 1.14, 1.15

tss-movial at dovecot.org tss-movial at dovecot.org
Wed Jun 28 19:31:09 EEST 2006


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

Modified Files:
	index-storage.c index-storage.h index-transaction.c 
Log Message:
Beginnings of joining mail-storage API more closely to mail-index, so that
mail-index could be directly used if needed. Currently only transactions
are joined.



Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- index-storage.c	30 May 2006 13:14:21 -0000	1.86
+++ index-storage.c	28 Jun 2006 16:31:06 -0000	1.87
@@ -379,6 +379,9 @@
 	index_cache_register_defaults(ibox);
 	ibox->view = mail_index_view_open(index);
 	ibox->keyword_names = mail_index_get_keywords(index);
+
+	array_idx_set(&index->mail_index_module_contexts,
+		      mail_storage_mail_index_module_id, &ibox);
 	return 0;
 }
 
@@ -395,6 +398,9 @@
 	if (ibox->recent_flags != NULL)
 		buffer_free(ibox->recent_flags);
 	i_free(ibox->cache_fields);
+
+	array_idx_clear(&ibox->index->mail_index_module_contexts,
+			mail_storage_mail_index_module_id);
 	pool_unref(box->pool);
 }
 

Index: index-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- index-storage.h	28 Jun 2006 13:10:49 -0000	1.103
+++ index-storage.h	28 Jun 2006 16:31:06 -0000	1.104
@@ -3,7 +3,7 @@
 
 #include "file-dotlock.h"
 #include "mail-storage-private.h"
-#include "mail-index.h"
+#include "mail-index-private.h"
 
 /* Max. mmap()ed size for a message */
 #define MAIL_MMAP_BLOCK_SIZE (1024*256)
@@ -84,8 +84,11 @@
 
 struct index_transaction_context {
 	struct mailbox_transaction_context mailbox_ctx;
+	struct mail_index_transaction_vfuncs super;
+
 	struct index_mailbox *ibox;
-        enum mailbox_transaction_flags flags;
+	enum mailbox_transaction_flags flags;
+	enum mailbox_sync_flags commit_flags;
 
 	struct mail_index_transaction *trans;
 	struct mail_index_view *trans_view;
@@ -178,9 +181,17 @@
 int index_storage_search_next_update_seq(struct mail_search_context *ctx);
 
 void index_transaction_init(struct index_transaction_context *t,
-			    struct index_mailbox *ibox,
-			    enum mailbox_transaction_flags flags);
-int index_transaction_commit(struct mailbox_transaction_context *t);
+			    struct index_mailbox *ibox);
+int index_transaction_finish_commit(struct index_transaction_context *t,
+				    uint32_t *log_file_seq_r,
+				    uoff_t *log_file_offset_r);
+void index_transaction_finish_rollback(struct index_transaction_context *t);
+
+struct mailbox_transaction_context *
+index_transaction_begin(struct mailbox *box,
+			enum mailbox_transaction_flags flags);
+int index_transaction_commit(struct mailbox_transaction_context *t,
+			     enum mailbox_sync_flags flags);
 void index_transaction_rollback(struct mailbox_transaction_context *t);
 
 bool index_keyword_array_cmp(const ARRAY_TYPE(keyword_indexes) *k1,

Index: index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-transaction.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- index-transaction.c	14 Jan 2006 18:47:42 -0000	1.14
+++ index-transaction.c	28 Jun 2006 16:31:06 -0000	1.15
@@ -6,19 +6,14 @@
 #include "index-mail.h"
 
 void index_transaction_init(struct index_transaction_context *t,
-			    struct index_mailbox *ibox,
-			    enum mailbox_transaction_flags flags)
+			    struct index_mailbox *ibox)
 {
 	t->mailbox_ctx.box = &ibox->box;
 	t->ibox = ibox;
-	t->flags = flags;
 
 	array_create(&t->mailbox_ctx.module_contexts, default_pool,
 		     sizeof(void *), 5);
 
-	t->trans = mail_index_transaction_begin(ibox->view,
-		(flags & MAILBOX_TRANSACTION_FLAG_HIDE) != 0,
-		(flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
 	t->trans_view = mail_index_transaction_open_updated_view(t->trans);
 	t->cache_view = mail_cache_view_open(ibox->cache, t->trans_view);
 	t->cache_trans = mail_cache_get_transaction(t->cache_view, t->trans);
@@ -33,21 +28,19 @@
 	i_free(t);
 }
 
-int index_transaction_commit(struct mailbox_transaction_context *_t)
+int index_transaction_finish_commit(struct index_transaction_context *t,
+				    uint32_t *log_file_seq_r,
+				    uoff_t *log_file_offset_r)
 {
-	struct index_transaction_context *t =
-		(struct index_transaction_context *)_t;
-	uint32_t seq;
-	uoff_t offset;
 	int ret;
 
-	ret = mail_index_transaction_commit(&t->trans, &seq, &offset);
+	ret = t->super.commit(t->trans, log_file_seq_r, log_file_offset_r);
 	if (ret < 0)
 		mail_storage_set_index_error(t->ibox);
 	else {
-		if (seq != 0) {
-			t->ibox->commit_log_file_seq = seq;
-			t->ibox->commit_log_file_offset = offset;
+		if (*log_file_seq_r != 0) {
+			t->ibox->commit_log_file_seq = *log_file_seq_r;
+			t->ibox->commit_log_file_offset = *log_file_offset_r;
 		}
 	}
 
@@ -55,11 +48,46 @@
 	return ret;
 }
 
+void index_transaction_finish_rollback(struct index_transaction_context *t)
+{
+	t->super.rollback(t->trans);
+	index_transaction_free(t);
+}
+
+struct mailbox_transaction_context *
+index_transaction_begin(struct mailbox *box,
+			enum mailbox_transaction_flags flags)
+{
+	struct index_mailbox *ibox = (struct index_mailbox *)box;
+	struct mail_index_transaction *t;
+	struct index_transaction_context *it;
+
+	t = mail_index_transaction_begin(ibox->view,
+		(flags & MAILBOX_TRANSACTION_FLAG_HIDE) != 0,
+		(flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
+
+	it = MAIL_STORAGE_TRANSACTION(t);
+	it->flags = flags;
+	return &it->mailbox_ctx;
+}
+int index_transaction_commit(struct mailbox_transaction_context *_t,
+			     enum mailbox_sync_flags flags)
+{
+	struct index_transaction_context *t =
+		(struct index_transaction_context *)_t;
+	struct mail_index_transaction *itrans = t->trans;
+	uint32_t seq;
+	uoff_t offset;
+
+	t->commit_flags = flags;
+	return mail_index_transaction_commit(&itrans, &seq, &offset);
+}
+
 void index_transaction_rollback(struct mailbox_transaction_context *_t)
 {
 	struct index_transaction_context *t =
 		(struct index_transaction_context *)_t;
+	struct mail_index_transaction *itrans = t->trans;
 
-	mail_index_transaction_rollback(&t->trans);
-	index_transaction_free(t);
+	mail_index_transaction_rollback(&itrans);
 }



More information about the dovecot-cvs mailing list