[dovecot-cvs] dovecot/src/lib-index mail-index-lock.c,1.14,1.15

cras at procontrol.fi cras at procontrol.fi
Mon May 24 02:52:17 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv12100

Modified Files:
	mail-index-lock.c 
Log Message:
when index's header size grows, fix it first time we get exclusive lock



Index: mail-index-lock.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-lock.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- a/mail-index-lock.c	16 May 2004 20:20:24 -0000	1.14
+++ b/mail-index-lock.c	23 May 2004 23:52:15 -0000	1.15
@@ -344,12 +344,16 @@
 	   for the main index file */
 	i_assert(index->log_locked);
 
-	/* wait two seconds for exclusive lock */
-	ret = mail_index_lock(index, F_WRLCK, 2, TRUE, lock_id_r);
-	if (ret > 0)
-		return 0;
-	if (ret < 0)
-		return -1;
+	/* if header size is smaller than what we have, we'll have to recreate
+	   the index to grow it. so don't even try regular locking. */
+	if (index->hdr->header_size >= sizeof(*index->hdr)) {
+		/* wait two seconds for exclusive lock */
+		ret = mail_index_lock(index, F_WRLCK, 2, TRUE, lock_id_r);
+		if (ret > 0)
+			return 0;
+		if (ret < 0)
+			return -1;
+	}
 
 	if (mail_index_lock_exclusive_copy(index) < 0)
 		return -1;



More information about the dovecot-cvs mailing list