[dovecot-cvs] dovecot/src/lib file-dotlock.c,1.1,1.2 file-dotlock.h,1.1,1.2
cras at procontrol.fi
cras at procontrol.fi
Fri Feb 14 14:56:34 EET 2003
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv22162/lib
Modified Files:
file-dotlock.c file-dotlock.h
Log Message:
Don't even try to override mbox dotlock if we can't get fcntl/flock.
Index: file-dotlock.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/file-dotlock.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- file-dotlock.c 12 Feb 2003 12:07:51 -0000 1.1
+++ file-dotlock.c 14 Feb 2003 12:56:32 -0000 1.2
@@ -143,7 +143,7 @@
struct stat st;
int fd;
- fd = open(lock_path, O_WRONLY | O_EXCL | O_CREAT, 0);
+ fd = open(lock_path, O_WRONLY | O_EXCL | O_CREAT, 0644);
if (fd == -1)
return -1;
@@ -180,8 +180,8 @@
int file_lock_dotlock(const char *path, int checkonly,
unsigned int timeout, unsigned int stale_timeout,
- void (*callback)(unsigned int secs_left, int stale,
- void *context),
+ int (*callback)(unsigned int secs_left, int stale,
+ void *context),
void *context, struct dotlock *dotlock_r)
{
const char *lock_path;
@@ -230,10 +230,15 @@
if (change_secs >= stale_notify_threshold &&
change_secs <= wait_left) {
- callback(stale_timeout - change_secs,
- TRUE, context);
+ if (!callback(stale_timeout -
+ change_secs,
+ TRUE, context)) {
+ /* we don't want to override */
+ lock_info.last_change = now;
+ }
} else {
- callback(wait_left, FALSE, context);
+ (void)callback(wait_left, FALSE,
+ context);
}
}
Index: file-dotlock.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/file-dotlock.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- file-dotlock.h 12 Feb 2003 12:07:51 -0000 1.1
+++ file-dotlock.h 14 Feb 2003 12:56:32 -0000 1.2
@@ -17,11 +17,15 @@
still locked, override the lock file.
If checkonly is TRUE, we don't actually create the lock file, only make
- sure that it doesn't exist. This is racy, so you shouldn't rely on it. */
+ sure that it doesn't exist. This is racy, so you shouldn't rely on it.
+
+ callback is called once in a while. stale is set to TRUE if stale lock is
+ detected and will be overridden in secs_left. If callback returns FALSE
+ then, the lock will not be overridden. */
int file_lock_dotlock(const char *path, int checkonly,
unsigned int timeout, unsigned int stale_timeout,
- void (*callback)(unsigned int secs_left, int stale,
- void *context),
+ int (*callback)(unsigned int secs_left, int stale,
+ void *context),
void *context, struct dotlock *dotlock_r);
/* Delete the dotlock file. Returns 1 if successful, 0 if the file was already
More information about the dovecot-cvs
mailing list