[dovecot-cvs] dovecot/src/lib-index mail-index-open.c,1.13,1.14 mail-index.c,1.67,1.68 mail-index.h,1.49,1.50

cras at procontrol.fi cras at procontrol.fi
Mon Nov 4 06:47:42 EET 2002


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

Modified Files:
	mail-index-open.c mail-index.c mail-index.h 
Log Message:
And more locking/syncing fixes. Now it's finally beginning to look sane
again.



Index: mail-index-open.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-open.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mail-index-open.c	2 Nov 2002 20:10:20 -0000	1.13
+++ mail-index-open.c	4 Nov 2002 04:47:40 -0000	1.14
@@ -214,8 +214,16 @@
 
 	/* sync ourself - before updating cache and compression which
 	   may happen because of this. */
-	if (!index->sync_and_lock(index, MAIL_LOCK_EXCLUSIVE, NULL))
+	if (!index->sync_and_lock(index, MAIL_LOCK_SHARED, NULL))
 		return FALSE;
+
+	/* we never want to keep shared lock if syncing happens to set it.
+	   either exclusive or nothing (NOTE: drop it directly, not through
+	   index->set_lock() so mbox lock won't be affected). */
+	if (index->lock_type == MAIL_LOCK_SHARED) {
+		if (!mail_index_set_lock(index, MAIL_LOCK_UNLOCK))
+			return FALSE;
+	}
 
 	if (!fast && (index->header->flags & MAIL_INDEX_FLAG_CACHE_FIELDS)) {
 		/* need to update cached fields */

Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- mail-index.c	2 Nov 2002 20:10:20 -0000	1.67
+++ mail-index.c	4 Nov 2002 04:47:40 -0000	1.68
@@ -339,7 +339,7 @@
 	debug_mprotect(index->mmap_base, index->mmap_full_length, index);
 
 	if (!mail_index_mmap_update(index)) {
-		(void)mail_index_set_lock(index, MAIL_LOCK_UNLOCK);
+		(void)index->set_lock(index, MAIL_LOCK_UNLOCK);
 		return FALSE;
 	}
 
@@ -377,7 +377,7 @@
 
 		if (lock_type == MAIL_LOCK_SHARED) {
 			/* drop exclusive lock */
-			return mail_index_set_lock(index, lock_type);
+			return index->set_lock(index, lock_type);
 		}
 	}
 
@@ -387,7 +387,7 @@
 		   removed. */
 		index->header->flags |= MAIL_INDEX_FLAG_FSCK;
 		if (!mail_index_fmdatasync(index, sizeof(MailIndexHeader))) {
-			(void)mail_index_set_lock(index, MAIL_LOCK_UNLOCK);
+			(void)index->set_lock(index, MAIL_LOCK_UNLOCK);
 			return FALSE;
 		}
 	}

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- mail-index.h	2 Nov 2002 20:10:20 -0000	1.49
+++ mail-index.h	4 Nov 2002 04:47:40 -0000	1.50
@@ -200,11 +200,11 @@
 	int (*fsck)(MailIndex *index);
 
 	/* Synchronize the index with the mailbox. Index must not have shared
-	   lock when calling this function. The lock_type specifies what
-	   locking state the index will be left, also locking mailbox file
-	   if needed. If changes is non-NULL, it's set to TRUE if any changes
-	   were noticed. */
-	int (*sync_and_lock)(MailIndex *index, MailLockType lock_type,
+	   lock when calling this function. The data_lock_type specifies what
+	   lock should be set to data file (mbox file). This function may
+	   leave the index in ANY locking state. If changes is non-NULL, it's
+	   set to TRUE if any changes were noticed. */
+	int (*sync_and_lock)(MailIndex *index, MailLockType data_lock_type,
 			     int *changes);
 
 	/* Returns the index header (never fails). The index needs to be




More information about the dovecot-cvs mailing list