[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-expunge.c,1.32,1.33

cras at procontrol.fi cras at procontrol.fi
Sun Nov 9 20:26:28 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory danu:/tmp/cvs-serv3937/lib-storage/index/mbox

Modified Files:
	mbox-expunge.c 
Log Message:
istream rewrite. instead of directly setting any limits to stream, you now
have to use i_stream_create_limit() to existing stream. this should make the
istreams much easier to create and understand how they work.



Index: mbox-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-expunge.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mbox-expunge.c	5 Nov 2003 08:42:13 -0000	1.32
+++ mbox-expunge.c	9 Nov 2003 18:26:26 -0000	1.33
@@ -37,7 +37,7 @@
 
 	/* mbox must be already opened, synced and locked at this point.
 	   we just want the istream. */
-	input = mbox_get_stream(ibox->index, 0, MAIL_LOCK_EXCLUSIVE);
+	input = mbox_get_stream(ibox->index, MAIL_LOCK_EXCLUSIVE);
 	if (input == NULL)
 		return NULL;
 
@@ -58,9 +58,9 @@
 
 static int mbox_move_data(struct mbox_expunge_context *ctx)
 {
+	struct istream *input;
 	const unsigned char *data;
 	size_t size;
-	uoff_t old_limit;
 	int failed;
 
 	i_stream_seek(ctx->input, ctx->move_offset);
@@ -76,15 +76,16 @@
 			i_stream_skip(ctx->input, 2);
 	}
 
-	old_limit = ctx->input->v_limit;
-	i_stream_set_read_limit(ctx->input, ctx->from_offset);
-	failed = o_stream_send_istream(ctx->output, ctx->input) < 0;
-	i_stream_set_read_limit(ctx->input, old_limit);
+	if (ctx->from_offset == 0)
+		failed = o_stream_send_istream(ctx->output, ctx->input) < 0;
+	else {
+		input = i_stream_create_limit(default_pool, ctx->input,
+					      0, ctx->from_offset);
+		failed = o_stream_send_istream(ctx->output, ctx->input) < 0;
+		i_stream_unref(input);
+	}
 
-	if (failed || (ctx->input->v_offset != ctx->from_offset &&
-		       ctx->from_offset != 0))
-		return FALSE;
-	return TRUE;
+	return !failed;
 }
 
 int mbox_storage_expunge_deinit(struct mail_expunge_context *_ctx)
@@ -94,7 +95,7 @@
 
 	if (ctx->expunges) {
 		if (!failed && ctx->move_offset != (uoff_t)-1) {
-			ctx->from_offset = ctx->input->v_limit;
+			ctx->from_offset = 0;
 			if (!mbox_move_data(ctx))
 				failed = TRUE;
 		} else if (failed && ctx->output->offset > 0) {



More information about the dovecot-cvs mailing list