[dovecot-cvs] dovecot/src/lib-index/mbox mbox-lock.c,1.13,1.14
cras at procontrol.fi
cras at procontrol.fi
Fri Nov 22 15:48:38 EET 2002
Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv24339/lib-index/mbox
Modified Files:
mbox-lock.c
Log Message:
Even if we didn't want to create dotlock when reading, first make sure it
doesn't exist. This is a bit racy, but can't help that.
Index: mbox-lock.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-lock.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mbox-lock.c 21 Nov 2002 20:13:32 -0000 1.13
+++ mbox-lock.c 22 Nov 2002 13:48:36 -0000 1.14
@@ -119,7 +119,7 @@
}
static int mbox_lock_dotlock(MailIndex *index, const char *path,
- time_t max_wait_time)
+ time_t max_wait_time, int checkonly)
{
struct stat st;
time_t now, last_change, last_mtime;
@@ -163,6 +163,17 @@
continue;
}
+ if (checkonly) {
+ /* we only wanted to check that the .lock file
+ doesn't exist. This is racy of course, but I don't
+ think there's any better way to do it really.
+ The fcntl/flock later does the real locking, so
+ problem comes only when someone uses only dotlock
+ locking, and we can't fix that without dotlocking
+ ourself (which we didn't want to do here) */
+ return TRUE;
+ }
+
fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0);
if (fd != -1) {
/* got it */
@@ -275,9 +286,10 @@
max_wait_time = time(NULL) + lock_timeout;
/* make .lock file first to protect overwriting the file */
- if (use_dotlock && index->mbox_dotlock_ino == 0 &&
- (lock_type == MAIL_LOCK_EXCLUSIVE || use_read_dotlock)) {
- if (!mbox_lock_dotlock(index, index->mbox_path, max_wait_time))
+ if (use_dotlock && index->mbox_dotlock_ino == 0) {
+ if (!mbox_lock_dotlock(index, index->mbox_path, max_wait_time,
+ lock_type == MAIL_LOCK_SHARED &&
+ !use_read_dotlock))
return FALSE;
}
More information about the dovecot-cvs
mailing list