diff src/plugins/lazy-expunge/lazy-expunge-plugin.c @ 6277:5f66277bbe40 HEAD

mail_index_lookup*() can't fail anymore. Changed several APIs not to return failure anymore.
author Timo Sirainen <tss@iki.fi>
date Sun, 12 Aug 2007 18:02:29 +0300
parents 913b188f4dd4
children 6a64e64fa3a3
line wrap: on
line diff
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Sun Aug 12 16:50:47 2007 +0300
+++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Sun Aug 12 18:02:29 2007 +0300
@@ -45,6 +45,8 @@
 
 	ARRAY_TYPE(seq_range) expunge_seqs;
 	struct mailbox *expunge_box;
+
+	bool failed;
 };
 
 const char *lazy_expunge_plugin_version = PACKAGE_VERSION;
@@ -91,7 +93,7 @@
 	return box;
 }
 
-static int lazy_expunge_mail_expunge(struct mail *_mail)
+static void lazy_expunge_mail_expunge(struct mail *_mail)
 {
 	struct lazy_expunge_transaction *lt =
 		LAZY_EXPUNGE_CONTEXT(_mail->transaction);
@@ -104,12 +106,12 @@
 		if (lt->expunge_box == NULL) {
 			mail_storage_set_critical(_mail->box->storage,
 				"lazy_expunge: Couldn't open expunge mailbox");
-			return -1;
+			lt->failed = TRUE;
+			return;
 		}
 	}
 
 	seq_range_array_add(&lt->expunge_seqs, 32, _mail->uid);
-	return 0;
 }
 
 static struct mailbox_transaction_context *
@@ -206,19 +208,24 @@
 
 static int
 lazy_expunge_transaction_commit(struct mailbox_transaction_context *ctx,
-				  enum mailbox_sync_flags flags,
-				  uint32_t *uid_validity_r,
-				  uint32_t *first_saved_uid_r,
-				  uint32_t *last_saved_uid_r)
+				enum mailbox_sync_flags flags,
+				uint32_t *uid_validity_r,
+				uint32_t *first_saved_uid_r,
+				uint32_t *last_saved_uid_r)
 {
 	union mailbox_module_context *mbox = LAZY_EXPUNGE_CONTEXT(ctx->box);
 	struct lazy_expunge_transaction *lt = LAZY_EXPUNGE_CONTEXT(ctx);
 	struct mailbox *srcbox = ctx->box;
 	int ret;
 
-	ret = mbox->super.transaction_commit(ctx, flags, uid_validity_r,
-					     first_saved_uid_r,
-					     last_saved_uid_r);
+	if (lt->failed) {
+		mbox->super.transaction_rollback(ctx);
+		ret = -1;
+	} else {
+		ret = mbox->super.transaction_commit(ctx, flags, uid_validity_r,
+						     first_saved_uid_r,
+						     last_saved_uid_r);
+	}
 
 	if (ret == 0 && array_is_created(&lt->expunge_seqs))
 		ret = lazy_expunge_move_expunges(srcbox, lt);