dovecot: If we expunged the first message but there were no othe...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 9 20:00:47 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/a5db1b4bc02c
changeset: 6250:a5db1b4bc02c
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 09 20:00:42 2007 +0300
description:
If we expunged the first message but there were no other changes, we might
have not actually expunged it.

diffstat:

1 file changed, 13 insertions(+), 3 deletions(-)
src/lib-storage/index/mbox/mbox-sync.c |   16 +++++++++++++---

diffs (33 lines):

diff -r 2ebca5088938 -r a5db1b4bc02c src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c	Thu Aug 09 19:27:57 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Thu Aug 09 20:00:42 2007 +0300
@@ -1648,8 +1648,17 @@ __again:
 		   before index syncing is started to avoid deadlocks, so we
 		   don't have much choice either (well, easy ones anyway). */
 		int lock_type = mbox->mbox_readonly ? F_RDLCK : F_WRLCK;
-		if (mbox_lock(mbox, lock_type, &lock_id) <= 0)
-			return -1;
+		int ret;
+
+		if ((ret = mbox_lock(mbox, lock_type, &lock_id)) <= 0) {
+			if (ret == 0 || lock_type == F_RDLCK)
+				return -1;
+
+			/* try as read-only */
+			if (mbox_lock(mbox, F_RDLCK, &lock_id) <= 0)
+				return -1;
+			mbox->mbox_readonly = TRUE;
+		}
 	}
 
 	if ((flags & MBOX_SYNC_LAST_COMMIT) != 0) {
@@ -1734,7 +1743,8 @@ __again:
 
 		if (mbox_sync_read_index_syncs(&sync_ctx, 1, &expunged) < 0)
 			return -1;
-		uid = index_sync_changes_get_next_uid(sync_ctx.sync_changes);
+		uid = expunged ? 1 :
+			index_sync_changes_get_next_uid(sync_ctx.sync_changes);
 		if (uid == 0) {
 			sync_ctx.index_sync_ctx = NULL;
 			mbox_sync_context_free(&sync_ctx);


More information about the dovecot-cvs mailing list