[dovecot-cvs] dovecot/src/lib-index mail-index-sync.c, 1.28, 1.29 mail-index.h, 1.125, 1.126

cras at dovecot.org cras at dovecot.org
Fri Jul 30 08:08:37 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv28577/lib-index

Modified Files:
	mail-index-sync.c mail-index.h 
Log Message:
Renamed mail_index_sync_end() to _commit() and added _rollback(). Fixed mbox
deadlocking issue.



Index: mail-index-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mail-index-sync.c	26 Jul 2004 18:52:06 -0000	1.28
+++ mail-index-sync.c	30 Jul 2004 05:08:35 -0000	1.29
@@ -289,7 +289,7 @@
 					  index->hdr->log_file_offset,
 					  seq, offset,
 					  MAIL_TRANSACTION_TYPE_MASK) < 0) {
-                mail_index_sync_end(ctx);
+                mail_index_sync_rollback(ctx);
 		return -1;
 	}
 
@@ -300,7 +300,7 @@
 	ctx->updates_buf = buffer_create_dynamic(default_pool,
 						 1024, (size_t)-1);
 	if (mail_index_sync_read_and_sort(ctx, sync_recent) < 0) {
-                mail_index_sync_end(ctx);
+                mail_index_sync_rollback(ctx);
 		return -1;
 	}
 
@@ -410,7 +410,21 @@
 		ctx->sync_appends;
 }
 
-int mail_index_sync_end(struct mail_index_sync_ctx *ctx)
+static void mail_index_sync_end(struct mail_index_sync_ctx *ctx)
+{
+	mail_index_unlock(ctx->index, ctx->lock_id);
+        i_assert(!ctx->index->map->write_to_disk);
+	mail_transaction_log_sync_unlock(ctx->index->log);
+	mail_index_view_close(ctx->view);
+
+	if (ctx->expunges_buf != NULL)
+		buffer_free(ctx->expunges_buf);
+	if (ctx->updates_buf != NULL)
+		buffer_free(ctx->updates_buf);
+	i_free(ctx);
+}
+
+int mail_index_sync_commit(struct mail_index_sync_ctx *ctx)
 {
 	const struct mail_index_header *hdr;
 	uint32_t seq, seq2;
@@ -449,19 +463,15 @@
 		}
 	}
 
-	mail_index_unlock(ctx->index, ctx->lock_id);
-        i_assert(!ctx->index->map->write_to_disk);
-	mail_transaction_log_sync_unlock(ctx->index->log);
-	mail_index_view_close(ctx->view);
-
-	if (ctx->expunges_buf != NULL)
-		buffer_free(ctx->expunges_buf);
-	if (ctx->updates_buf != NULL)
-		buffer_free(ctx->updates_buf);
-	i_free(ctx);
+	mail_index_sync_end(ctx);
 	return ret;
 }
 
+void mail_index_sync_rollback(struct mail_index_sync_ctx *ctx)
+{
+	mail_index_sync_end(ctx);
+}
+
 void mail_index_sync_flags_apply(const struct mail_index_sync_rec *sync_rec,
 				 uint8_t *flags, keywords_mask_t keywords)
 {

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- mail-index.h	26 Jul 2004 18:52:07 -0000	1.125
+++ mail-index.h	30 Jul 2004 05:08:35 -0000	1.126
@@ -198,8 +198,8 @@
    sync types, then they might). You must go through all of them and update
    the mailbox accordingly.
 
-   None of the changes actually show up in index until at
-   mail_index_sync_end().
+   None of the changes actually show up in index until after successful
+   mail_index_sync_commit().
 
    Returned sequence numbers describe the mailbox state at the beginning of
    synchronization, ie. expunges don't affect them.
@@ -217,8 +217,11 @@
 			 struct mail_index_sync_rec *sync_rec);
 /* Returns 1 if there's more to sync, 0 if not. */
 int mail_index_sync_have_more(struct mail_index_sync_ctx *ctx);
-/* End synchronization by unlocking the index and closing the view. */
-int mail_index_sync_end(struct mail_index_sync_ctx *ctx);
+/* Commit synchronization by writing all changes to mail index file. */
+int mail_index_sync_commit(struct mail_index_sync_ctx *ctx);
+/* Rollback synchronization - none of the changes listed by sync_next() are
+   actually written to index file. */
+void mail_index_sync_rollback(struct mail_index_sync_ctx *ctx);
 
 /* Mark index file corrupted. Invalidates all views. */
 void mail_index_mark_corrupted(struct mail_index *index);



More information about the dovecot-cvs mailing list