[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-lock.c, 1.12,
1.13
cras at dovecot.org
cras at dovecot.org
Sun Jan 16 21:18:27 EET 2005
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv4353/lib-storage/index/mbox
Modified Files:
mbox-lock.c
Log Message:
Changed dotlocking API.
Index: mbox-lock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-lock.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mbox-lock.c 20 Dec 2004 12:44:19 -0000 1.12
+++ mbox-lock.c 16 Jan 2005 19:18:25 -0000 1.13
@@ -227,29 +227,33 @@
time_t max_wait_time __attr_unused__)
{
struct index_mailbox *ibox = ctx->ibox;
+ struct dotlock_settings set;
int ret;
if (lock_type == F_UNLCK) {
- if (ibox->mbox_dotlock.ino == 0)
+ if (!ibox->mbox_dotlocked)
return 1;
- if (file_unlock_dotlock(ibox->path, &ibox->mbox_dotlock) <= 0) {
- mbox_set_syscall_error(ibox, "file_unlock_dotlock()");
+ if (file_dotlock_delete(&ibox->mbox_dotlock) <= 0) {
+ mbox_set_syscall_error(ibox, "file_dotlock_delete()");
ret = -1;
}
- ibox->mbox_dotlock.ino = 0;
+ ibox->mbox_dotlocked = FALSE;
return 1;
}
- if (ibox->mbox_dotlock.ino != 0)
+ if (ibox->mbox_dotlocked)
return 1;
ctx->dotlock_last_stale = -1;
- ret = file_lock_dotlock(ibox->path, NULL, FALSE, lock_timeout,
- dotlock_change_timeout, 0,
- dotlock_callback, ctx, &ibox->mbox_dotlock);
+ memset(&set, 0, sizeof(set));
+ set.timeout = lock_timeout;
+ set.stale_timeout = dotlock_change_timeout;
+ set.callback = dotlock_callback;
+ set.context = ctx;
+ ret = file_dotlock_create(&set, ibox->path, 0, &ibox->mbox_dotlock);
if (ret < 0) {
mbox_set_syscall_error(ibox, "file_lock_dotlock()");
return -1;
@@ -259,6 +263,8 @@
"Timeout while waiting for lock");
return 0;
}
+ ibox->mbox_dotlocked = TRUE;
+
if (mbox_file_open_latest(ctx, lock_type) < 0)
return -1;
return 1;
More information about the dovecot-cvs
mailing list