[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync.c, 1.112, 1.113

cras at dovecot.org cras at dovecot.org
Tue Oct 26 01:10:35 EEST 2004


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

Modified Files:
	mbox-sync.c 
Log Message:
last fix was wrong



Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- mbox-sync.c	25 Oct 2004 21:55:15 -0000	1.112
+++ mbox-sync.c	25 Oct 2004 22:10:33 -0000	1.113
@@ -603,7 +603,7 @@
 mbox_sync_handle_missing_space(struct mbox_sync_mail_context *mail_ctx)
 {
 	struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
-	uoff_t end_offset, move_diff, extra_space;
+	uoff_t end_offset, move_diff, extra_space, needed_space;
 	uint32_t last_seq;
 
 	buffer_append(sync_ctx->mails, &mail_ctx->mail, sizeof(mail_ctx->mail));
@@ -620,15 +620,18 @@
 
 	/* we have enough space now */
 	if (mail_ctx->mail.uid == 0) {
-		/* this message was expunged. fill more or less of the space. */
+		/* this message was expunged. fill more or less of the space.
+		   space_diff now consists of a negative "bytes needed" sum,
+		   plus the expunged space of this message. so it contains how
+		   many bytes of _extra_ space we have. */
 		extra_space = MBOX_HEADER_PADDING *
 			(sync_ctx->seq - sync_ctx->need_space_seq + 1);
-		if ((uoff_t)sync_ctx->space_diff > extra_space) {
+		needed_space = mail_ctx->mail.space - sync_ctx->space_diff;
+		if ((uoff_t)sync_ctx->space_diff > needed_space + extra_space) {
 			/* don't waste too much on padding */
-			i_assert(mail_ctx->mail.space > (off_t)extra_space);
-			sync_ctx->expunged_space =
-				mail_ctx->mail.space - extra_space;
-			sync_ctx->space_diff = extra_space;
+			sync_ctx->expunged_space = mail_ctx->mail.space -
+				(needed_space + extra_space);
+			sync_ctx->space_diff = needed_space + extra_space;
 		} else {
 			extra_space = sync_ctx->space_diff;
 		}



More information about the dovecot-cvs mailing list