[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-mail.c, 1.39, 1.40 mbox-storage.h, 1.53, 1.54 mbox-sync.c, 1.209, 1.210

tss at dovecot.org tss at dovecot.org
Tue Apr 17 18:09:20 EEST 2007


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

Modified Files:
	mbox-mail.c mbox-storage.h mbox-sync.c 
Log Message:
Call sync_notify() once at the end of syncing. Allow accessing mails even
while syncing, as long as it's safe to do so.



Index: mbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-mail.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- mbox-mail.c	30 Mar 2007 12:44:06 -0000	1.39
+++ mbox-mail.c	17 Apr 2007 15:09:14 -0000	1.40
@@ -39,8 +39,8 @@
 	int ret, try;
 	bool deleted;
 
-	if (mail->mail.mail.expunged)
-		return 0;
+	if (mail->mail.mail.expunged || mbox->syncing)
+		return -1;
 
 	for (try = 0; try < 2; try++) {
 		if (mbox->mbox_lock_type == F_UNLCK) {
@@ -74,10 +74,8 @@
 			break;
 		}
 		if (ret < 0) {
-			if (deleted) {
+			if (deleted)
 				mail->mail.mail.expunged = TRUE;
-				return 0;
-			}
 			return -1;
 		}
 
@@ -90,7 +88,7 @@
 			"Losing sync for mail uid=%u in mbox file %s",
 			mail->mail.mail.uid, mbox->path);
 	}
-	return 1;
+	return 0;
 }
 
 static time_t mbox_mail_get_received_date(struct mail *_mail)
@@ -104,7 +102,7 @@
 	if (data->received_date != (time_t)-1)
 		return data->received_date;
 
-	if (mbox_mail_seek(mail) <= 0)
+	if (mbox_mail_seek(mail) < 0)
 		return (time_t)-1;
 	data->received_date =
 		istream_raw_mbox_get_received_time(mbox->mbox_stream);
@@ -147,7 +145,7 @@
 
 	switch (field) {
 	case MAIL_FETCH_FROM_ENVELOPE:
-		if (mbox_mail_seek(mail) <= 0)
+		if (mbox_mail_seek(mail) < 0)
 			return NULL;
 
 		return istream_raw_mbox_get_sender(mbox->mbox_stream);
@@ -179,7 +177,7 @@
 	struct istream *stream;
 	uoff_t hdr_offset, body_offset, body_size;
 
-	if (mbox_mail_seek(mail) <= 0)
+	if (mbox_mail_seek(mail) < 0)
 		return (uoff_t)-1;
 
 	/* our header size varies, so don't do any caching */
@@ -206,7 +204,7 @@
 	uoff_t offset;
 
 	if (data->stream == NULL) {
-		if (mbox_mail_seek(mail) <= 0)
+		if (mbox_mail_seek(mail) < 0)
 			return NULL;
 
 		raw_stream = mbox->mbox_stream;

Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- mbox-storage.h	30 Mar 2007 19:08:12 -0000	1.53
+++ mbox-storage.h	17 Apr 2007 15:09:14 -0000	1.54
@@ -47,6 +47,7 @@
 	unsigned int mbox_very_dirty_syncs:1;
 	unsigned int mbox_save_md5:1;
 	unsigned int mbox_dotlocked:1;
+	unsigned int syncing:1;
 };
 
 struct mbox_transaction_context {

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- mbox-sync.c	17 Apr 2007 12:41:29 -0000	1.209
+++ mbox-sync.c	17 Apr 2007 15:09:14 -0000	1.210
@@ -1686,7 +1686,7 @@
 	array_free(&sync_ctx->syncs);
 }
 
-int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags)
+static int mbox_sync_int(struct mbox_mailbox *mbox, enum mbox_sync_flags flags)
 {
 	struct mail_index_sync_ctx *index_sync_ctx;
 	struct mail_index_view *sync_view;
@@ -1904,6 +1904,19 @@
 	return ret;
 }
 
+int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags)
+{
+	int ret;
+
+	mbox->syncing = TRUE;
+	ret = mbox_sync_int(mbox, flags);
+	mbox->syncing = FALSE;
+
+	if (mbox->ibox.box.v.sync_notify != NULL)
+		mbox->ibox.box.v.sync_notify(&mbox->ibox.box, 0, 0);
+	return ret;
+}
+
 struct mailbox_sync_context *
 mbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
 {



More information about the dovecot-cvs mailing list