[dovecot-cvs] dovecot/src/lib-index/maildir maildir-expunge.c,1.5,1.6 maildir-sync.c,1.60,1.61 maildir-update-flags.c,1.8,1.9

cras at procontrol.fi cras at procontrol.fi
Mon Aug 11 05:56:39 EEST 2003


Update of /home/cvs/dovecot/src/lib-index/maildir
In directory danu:/tmp/cvs-serv9360/lib-index/maildir

Modified Files:
	maildir-expunge.c maildir-sync.c maildir-update-flags.c 
Log Message:
Save sync stamp in index header rather than in file's mtime.



Index: maildir-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-expunge.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- maildir-expunge.c	10 Aug 2003 23:56:23 -0000	1.5
+++ maildir-expunge.c	11 Aug 2003 01:56:37 -0000	1.6
@@ -39,12 +39,12 @@
 		/* if we're in out-of-space condition, reset it since we'll
 		   probably have enough space now. */
 		index->maildir_keep_new = FALSE;
-		if (index->next_dirty_flush != 0)
-			index->next_dirty_flush = ioloop_time;
+		if (index->next_dirty_flags_flush != 0)
+			index->next_dirty_flags_flush = ioloop_time;
 
 		/* cur/ was updated, set it dirty-synced */
-		index->maildir_cur_dirty = ioloop_time;
-		index->file_sync_stamp = ioloop_time;
+		index->sync_dirty_stamp = ioloop_time;
+		index->sync_stamp = ioloop_time;
 	}
 	return TRUE;
 }

Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-sync.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- maildir-sync.c	10 Aug 2003 23:56:23 -0000	1.60
+++ maildir-sync.c	11 Aug 2003 01:56:37 -0000	1.61
@@ -1084,14 +1084,6 @@
 	if (!maildir_try_flush_dirty_flags(ctx->index, FALSE))
 		return FALSE;
 
-	if (index->fd != -1) {
-		/* FIXME: file_sync_stamp should be in index file's headers.
-		   it should also contain maildir_cur_dirty. */
-		if (fstat(index->fd, &st) < 0)
-			return index_set_syscall_error(index, "fstat()");
-		index->file_sync_stamp = st.st_mtime;
-	}
-
 	if (stat(ctx->new_dir, &st) < 0) {
 		index_file_set_syscall_error(index, ctx->new_dir, "stat()");
 		return FALSE;
@@ -1110,9 +1102,17 @@
 			return FALSE;
 	}
 
-	if (cur_mtime != index->file_sync_stamp ||
-	    (index->maildir_cur_dirty != 0 &&
-	     index->maildir_cur_dirty < ioloop_time - MAILDIR_SYNC_SECS)) {
+	if (cur_mtime != index->sync_stamp &&
+	    index->sync_dirty_stamp == 0) {
+		/* update index->sync_stamp from header.
+		   set_lock() does it automatically. */
+		if (!index->set_lock(index, MAIL_LOCK_EXCLUSIVE))
+			return FALSE;
+	}
+
+	if (cur_mtime != index->sync_stamp ||
+	    (index->sync_dirty_stamp != 0 &&
+	     index->sync_dirty_stamp < ioloop_time - MAILDIR_SYNC_SECS)) {
 		/* cur/ changed, or delayed cur/ check */
 		if (changes != NULL)
 			*changes = TRUE;
@@ -1150,20 +1150,20 @@
 			index->header->flags &= ~MAIL_INDEX_FLAG_MAILDIR_NEW;
 	}
 
-	if (index->maildir_cur_dirty == 0 ||
-	    index->maildir_cur_dirty < ioloop_time - MAILDIR_SYNC_SECS) {
+	if (index->sync_dirty_stamp == 0 ||
+	    index->sync_dirty_stamp < ioloop_time - MAILDIR_SYNC_SECS) {
 		if (cur_mtime >= ioloop_time - MAILDIR_SYNC_SECS)
-			index->maildir_cur_dirty = cur_mtime;
+			index->sync_dirty_stamp = cur_mtime;
 		else if (ctx->new_count == 0 || !ctx->new_mails_cur)
-			index->maildir_cur_dirty = 0;
+			index->sync_dirty_stamp = 0;
 		else {
 			/* uidlist is locked, wait for a while before
 			   trying again */
-			index->maildir_cur_dirty = ioloop_time;
+			index->sync_dirty_stamp = ioloop_time;
 		}
 	}
 
-	index->file_sync_stamp = cur_mtime;
+	index->sync_stamp = cur_mtime;
 	if (ctx->new_dent == NULL &&
 	    (ctx->new_count == 0 || !ctx->new_mails_new))
 		index->last_new_mtime = new_mtime;
@@ -1268,8 +1268,8 @@
 			return FALSE;
 		}
 
-		cur_changed = st.st_mtime != index->file_sync_stamp ||
-			index->maildir_cur_dirty != 0;
+		cur_changed = st.st_mtime != index->sync_stamp ||
+			index->sync_dirty_stamp != 0;
 	}
 
 	if (!cur_changed) {

Index: maildir-update-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-update-flags.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- maildir-update-flags.c	10 Aug 2003 23:56:23 -0000	1.8
+++ maildir-update-flags.c	11 Aug 2003 01:56:37 -0000	1.9
@@ -60,8 +60,8 @@
 	struct mail_index_record *rec;
 	int ret, dirty = FALSE;
 
-	if (index->next_dirty_flush == 0 ||
-	    (ioloop_time < index->next_dirty_flush && !force))
+	if (index->next_dirty_flags_flush == 0 ||
+	    (ioloop_time < index->next_dirty_flags_flush && !force))
 		return TRUE;
 
 	if (!index->set_lock(index, MAIL_LOCK_EXCLUSIVE))
@@ -91,9 +91,9 @@
 
 	if (!dirty) {
 		index->header->flags &= ~MAIL_INDEX_HDR_FLAG_DIRTY_MESSAGES;
-		index->next_dirty_flush = 0;
+		index->next_dirty_flags_flush = 0;
 	} else {
-		index->next_dirty_flush =
+		index->next_dirty_flags_flush =
 			ioloop_time + MAILDIR_DIRTY_FLUSH_TIMEOUT;
 	}
 
@@ -177,8 +177,8 @@
 	}
 
 	/* cur/ was updated, set it dirty-synced */
-	index->file_sync_stamp = ioloop_time;
-	index->maildir_cur_dirty = ioloop_time;
+	index->sync_stamp = ioloop_time;
+	index->sync_dirty_stamp = ioloop_time;
 	ctx->found = TRUE;
 	return 1;
 }
@@ -218,7 +218,7 @@
 				MAIL_INDEX_HDR_FLAG_DIRTY_MESSAGES;
 		}
 
-		index->next_dirty_flush =
+		index->next_dirty_flags_flush =
 			ioloop_time + MAILDIR_DIRTY_FLUSH_TIMEOUT;
 	} else if (ctx.new_fname != NULL) {
 		maildir_index_update_filename(index, rec->uid,



More information about the dovecot-cvs mailing list