changeset 552:33be9c9f3b3a HEAD

mbox locking wasn't working.
author Timo Sirainen <tss@iki.fi>
date Tue, 29 Oct 2002 08:46:47 +0200
parents ac68ab739a4d
children c31add7eaa57
files src/lib-index/mail-index.c src/lib-index/mail-index.h src/lib-index/mbox/mbox-lock.c
diffstat 3 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Tue Oct 29 08:29:50 2002 +0200
+++ b/src/lib-index/mail-index.c	Tue Oct 29 08:46:47 2002 +0200
@@ -248,10 +248,6 @@
 	}
 }
 
-#define MAIL_LOCK_TO_FLOCK(lock_type) \
-        ((lock_type) == MAIL_LOCK_UNLOCK ? F_UNLCK : \
-		(lock_type) == MAIL_LOCK_SHARED ? F_RDLCK : F_WRLCK)
-
 int mail_index_try_lock(MailIndex *index, MailLockType lock_type)
 {
 	int ret;
--- a/src/lib-index/mail-index.h	Tue Oct 29 08:29:50 2002 +0200
+++ b/src/lib-index/mail-index.h	Tue Oct 29 08:46:47 2002 +0200
@@ -471,4 +471,9 @@
 	(sizeof(MailIndexHeader) + \
 	 INDEX_MIN_RECORDS_COUNT * sizeof(MailIndexRecord))
 
+/* MailLockType to fcntl() lock type */
+#define MAIL_LOCK_TO_FLOCK(lock_type) \
+        ((lock_type) == MAIL_LOCK_UNLOCK ? F_UNLCK : \
+		(lock_type) == MAIL_LOCK_SHARED ? F_RDLCK : F_WRLCK)
+
 #endif
--- a/src/lib-index/mbox/mbox-lock.c	Tue Oct 29 08:29:50 2002 +0200
+++ b/src/lib-index/mbox/mbox-lock.c	Tue Oct 29 08:46:47 2002 +0200
@@ -28,11 +28,11 @@
 #define STALE_LOCK_TIMEOUT (60*10)
 
 #ifdef HAVE_FLOCK
-static int mbox_lock_flock(MailIndex *index, int lock_type)
+static int mbox_lock_flock(MailIndex *index, MailLockType lock_type)
 {
-	if (lock_type == F_WRLCK)
+	if (lock_type == MAIL_LOCK_EXCLUSIVE)
 		lock_type = LOCK_EX;
-	else if (lock_type == F_RDLCK)
+	else if (lock_type == MAIL_LOCK_SHARED)
 		lock_type = LOCK_SH;
 	else
 		lock_type = LOCK_UN;
@@ -45,11 +45,11 @@
 }
 #endif
 
-static int mbox_lock_fcntl(MailIndex *index, int lock_type)
+static int mbox_lock_fcntl(MailIndex *index, MailLockType lock_type)
 {
 	struct flock fl;
 
-	fl.l_type = lock_type;
+	fl.l_type = MAIL_LOCK_TO_FLOCK(lock_type);
 	fl.l_whence = SEEK_SET;
 	fl.l_start = 0;
 	fl.l_len = 0;