[dovecot-cvs] dovecot/src/lib-storage/index index-copy.c,1.27,1.28 index-expunge.c,1.15,1.16 index-fetch.c,1.46,1.47 index-search.c,1.73,1.74 index-status.c,1.25,1.26 index-storage.h,1.37,1.38 index-sync.c,1.24,1.25 index-update-flags.c,1.21,1.22

cras at procontrol.fi cras at procontrol.fi
Sun Jun 15 07:42:31 EEST 2003


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

Modified Files:
	index-copy.c index-expunge.c index-fetch.c index-search.c 
	index-status.c index-storage.h index-sync.c 
	index-update-flags.c 
Log Message:
Only NOOP and CHECK will now always do a real mailbox sync. Other commands
will also do it but no often than once in 5 seconds. Also with maildir we
don't anymore try to sync it before running commands since syncing is now
done automatically whenever we try to access a file that doesn't exist.



Index: index-copy.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-copy.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- index-copy.c	22 Jan 2003 19:23:28 -0000	1.27
+++ index-copy.c	15 Jun 2003 03:42:29 -0000	1.28
@@ -64,7 +64,8 @@
 		if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
 			return FALSE;
 	} else {
-		if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_SHARED))
+		if (!index_storage_sync_and_lock(ibox, TRUE, TRUE,
+						 MAIL_LOCK_SHARED))
 			return FALSE;
 	}
 

Index: index-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-expunge.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- index-expunge.c	8 May 2003 11:30:32 -0000	1.15
+++ index-expunge.c	15 Jun 2003 03:42:29 -0000	1.16
@@ -78,7 +78,8 @@
 	if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
 		return FALSE;
 
-	if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_EXCLUSIVE))
+	if (!index_storage_sync_and_lock(ibox, FALSE, TRUE,
+					 MAIL_LOCK_EXCLUSIVE))
 		return FALSE;
 
 	/* modifylog must be marked synced before expunging

Index: index-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- index-fetch.c	9 Mar 2003 09:01:01 -0000	1.46
+++ index-fetch.c	15 Jun 2003 03:42:29 -0000	1.47
@@ -42,7 +42,8 @@
 
 	check_mail = (client_workarounds &
 		      WORKAROUND_OE6_FETCH_NO_NEWMAIL) == 0;
-	if (!index_storage_sync_and_lock(ibox, check_mail, MAIL_LOCK_SHARED))
+	if (!index_storage_sync_and_lock(ibox, check_mail, TRUE,
+					 MAIL_LOCK_SHARED))
 		return NULL;
 
 	if (update_seen != NULL && *update_seen &&

Index: index-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- index-search.c	14 Jun 2003 17:43:26 -0000	1.73
+++ index-search.c	15 Jun 2003 03:42:29 -0000	1.74
@@ -926,7 +926,7 @@
 		return NULL;
 	}
 
-	if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_SHARED))
+	if (!index_storage_sync_and_lock(ibox, TRUE, TRUE, MAIL_LOCK_SHARED))
 		return NULL;
 
 	ctx = i_new(struct mail_search_context, 1);

Index: index-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-status.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- index-status.c	30 May 2003 01:53:07 -0000	1.25
+++ index-status.c	15 Jun 2003 03:42:29 -0000	1.26
@@ -89,7 +89,8 @@
 	if ((items & STATUS_MESSAGE_COUNTS) != 0) {
 		/* if we're doing STATUS for selected mailbox, we have to sync
 		   it first or STATUS reply may give different data */
-		if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
+		if (!index_storage_sync_and_lock(ibox, TRUE, FALSE,
+						 MAIL_LOCK_UNLOCK))
 			return FALSE;
 
 		if (!index_storage_sync_modifylog(ibox, FALSE)) {

Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- index-storage.h	14 Jun 2003 17:38:06 -0000	1.37
+++ index-storage.h	15 Jun 2003 03:42:29 -0000	1.38
@@ -52,7 +52,8 @@
 		   int readonly, int fast);
 int index_storage_close(struct mailbox *box);
 
-int index_storage_sync_and_lock(struct index_mailbox *ibox, int sync_size,
+int index_storage_sync_and_lock(struct index_mailbox *ibox,
+				int sync_size, int minimal_sync,
 				enum mail_lock_type data_lock_type);
 int index_storage_sync_modifylog(struct index_mailbox *ibox, int hide_deleted);
 
@@ -82,7 +83,7 @@
 int index_storage_get_status(struct mailbox *box,
 			     enum mailbox_status_items items,
 			     struct mailbox_status *status);
-int index_storage_sync(struct mailbox *box, int sync_expunges);
+int index_storage_sync(struct mailbox *box, enum mail_sync_flags flags);
 int index_storage_update_flags(struct mailbox *box, const char *messageset,
 			       int uidset, const struct mail_full_flags *flags,
 			       enum modify_type modify_type, int notify,

Index: index-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- index-sync.c	14 Feb 2003 10:46:44 -0000	1.24
+++ index-sync.c	15 Jun 2003 03:42:29 -0000	1.25
@@ -7,6 +7,9 @@
 #include "mail-modifylog.h"
 #include "mail-custom-flags.h"
 
+/* How often to do full sync when fast sync flag is set. */
+#define MAILBOX_FULL_SYNC_INTERVAL 5
+
 static void index_storage_sync_size(struct index_mailbox *ibox)
 {
 	struct mail_storage *storage = ibox->box.storage;
@@ -29,7 +32,8 @@
 	}
 }
 
-int index_storage_sync_and_lock(struct index_mailbox *ibox, int sync_size,
+int index_storage_sync_and_lock(struct index_mailbox *ibox,
+				int sync_size, int minimal_sync,
 				enum mail_lock_type data_lock_type)
 {
 	struct mail_storage *storage = ibox->box.storage;
@@ -39,7 +43,8 @@
         set_shared_lock = ibox->index->lock_type != MAIL_LOCK_EXCLUSIVE;
 
         index_storage_init_lock_notify(ibox);
-	failed = !index->sync_and_lock(index, data_lock_type, &changes);
+	failed = !index->sync_and_lock(index, minimal_sync,
+				       data_lock_type, &changes);
 	ibox->index->set_lock_notify_callback(ibox->index, NULL, NULL);
 
 	if (!failed) {
@@ -209,19 +214,29 @@
 	return TRUE;
 }
 
-int index_storage_sync(struct mailbox *box, int sync_expunges)
+int index_storage_sync(struct mailbox *box, enum mail_sync_flags flags)
 {
 	struct index_mailbox *ibox = (struct index_mailbox *) box;
 	int ret;
 
-	ibox->sync_last_check = ioloop_time;
+	if ((flags & MAIL_SYNC_FLAG_FAST) == 0 ||
+	    ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <= ioloop_time) {
+		ibox->sync_last_check = ioloop_time;
 
-	if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_UNLOCK))
-		return FALSE;
+		if (!index_storage_sync_and_lock(ibox, FALSE, FALSE,
+						 MAIL_LOCK_UNLOCK))
+			return FALSE;
+	} else {
+		/* check only modify log */
+		if (!index_storage_lock(ibox, MAIL_LOCK_SHARED)) {
+			(void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK);
+			return FALSE;
+		}
+	}
 
 	/* FIXME: we could sync flags always, but expunges in the middle
 	   could make it a bit more difficult and slower */
-	if (sync_expunges ||
+	if ((flags & MAIL_SYNC_FLAG_NO_EXPUNGES) == 0 ||
 	    mail_modifylog_get_expunge_count(ibox->index->modifylog) == 0)
 		ret = index_storage_sync_modifylog(ibox, FALSE);
 	else

Index: index-update-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-update-flags.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- index-update-flags.c	8 May 2003 11:35:28 -0000	1.21
+++ index-update-flags.c	15 Jun 2003 03:42:29 -0000	1.22
@@ -83,7 +83,7 @@
 	if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
 		return FALSE;
 
-	if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
+	if (!index_storage_sync_and_lock(ibox, TRUE, TRUE, MAIL_LOCK_UNLOCK))
 		return FALSE;
 
 	mail_flags &= ~MAIL_RECENT; /* \Recent can't be changed */



More information about the dovecot-cvs mailing list