[dovecot-cvs] dovecot/src/lib-storage/subscription-file
subscription-file.c, 1.25, 1.26
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/subscription-file
In directory talvi:/tmp/cvs-serv4353/lib-storage/subscription-file
Modified Files:
subscription-file.c
Log Message:
Changed dotlocking API.
Index: subscription-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/subscription-file/subscription-file.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- subscription-file.c 9 May 2004 23:32:44 -0000 1.25
+++ subscription-file.c 16 Jan 2005 19:18:25 -0000 1.26
@@ -70,6 +70,8 @@
int subsfile_set_subscribed(struct mail_storage *storage, const char *path,
const char *temp_prefix, const char *name, int set)
{
+ struct dotlock_settings dotlock_set;
+ struct dotlock *dotlock;
const char *line;
struct istream *input;
struct ostream *output;
@@ -78,12 +80,14 @@
if (strcasecmp(name, "INBOX") == 0)
name = "INBOX";
+ memset(&dotlock_set, 0, sizeof(dotlock_set));
+ dotlock_set.temp_prefix = temp_prefix;
+ dotlock_set.timeout = SUBSCRIPTION_FILE_LOCK_TIMEOUT;
+ dotlock_set.stale_timeout = SUBSCRIPTION_FILE_CHANGE_TIMEOUT;
+ dotlock_set.immediate_stale_timeout = SUBSCRIPTION_FILE_IMMEDIATE_TIMEOUT;
+
/* FIXME: set lock notification callback */
- fd_out = file_dotlock_open(path, temp_prefix, NULL,
- SUBSCRIPTION_FILE_LOCK_TIMEOUT,
- SUBSCRIPTION_FILE_CHANGE_TIMEOUT,
- SUBSCRIPTION_FILE_IMMEDIATE_TIMEOUT,
- NULL, NULL);
+ fd_out = file_dotlock_open(&dotlock_set, path, 0, &dotlock);
if (fd_out == -1) {
if (errno == EAGAIN) {
mail_storage_set_error(storage,
@@ -98,7 +102,7 @@
fd_in = open(path, O_RDONLY);
if (fd_in == -1 && errno != ENOENT) {
subsfile_set_syscall_error(storage, "open()", path);
- file_dotlock_delete(path, NULL, fd_out);
+ (void)file_dotlock_delete(&dotlock);
return -1;
}
@@ -138,13 +142,15 @@
o_stream_unref(output);
if (failed || (set && found) || (!set && !found)) {
- if (file_dotlock_delete(path, NULL, fd_out) < 0) {
+ if (file_dotlock_delete(&dotlock) < 0) {
subsfile_set_syscall_error(storage,
"file_dotlock_delete()", path);
failed = TRUE;
}
} else {
- if (file_dotlock_replace(path, NULL, fd_out, TRUE) < 0) {
+ enum dotlock_replace_flags flags =
+ DOTLOCK_REPLACE_FLAG_VERIFY_OWNER;
+ if (file_dotlock_replace(&dotlock, flags) < 0) {
subsfile_set_syscall_error(storage,
"file_dotlock_replace()", path);
failed = TRUE;
More information about the dovecot-cvs
mailing list