dovecot-2.0: mdbox: Recent change enabled dotlocking always, ins...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Apr 26 17:46:18 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/4f6fa828d0c9
changeset: 11191:4f6fa828d0c9
user: Timo Sirainen <tss at iki.fi>
date: Mon Apr 26 17:46:13 2010 +0300
description:
mdbox: Recent change enabled dotlocking always, instead of using flock.
diffstat:
src/lib-storage/index/dbox-common/dbox-file.c | 24 ++++++++++++------------
src/lib-storage/index/dbox-common/dbox-file.h | 10 ++++------
2 files changed, 16 insertions(+), 18 deletions(-)
diffs (83 lines):
diff -r b13146b6a91b -r 4f6fa828d0c9 src/lib-storage/index/dbox-common/dbox-file.c
--- a/src/lib-storage/index/dbox-common/dbox-file.c Mon Apr 26 15:43:01 2010 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-file.c Mon Apr 26 17:46:13 2010 +0300
@@ -25,7 +25,7 @@
#define DBOX_READ_BLOCK_SIZE 4096
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
+#ifndef DBOX_FILE_LOCK_METHOD_FLOCK
static const struct dotlock_settings dotlock_set = {
.stale_timeout = 60*10,
.use_excl_lock = TRUE
@@ -298,20 +298,20 @@
i_assert(file->fd != -1);
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
+#ifdef DBOX_FILE_LOCK_METHOD_FLOCK
+ ret = file_try_lock(file->fd, file->cur_path, F_WRLCK,
+ FILE_LOCK_METHOD_FLOCK, &file->lock);
+ if (ret < 0) {
+ mail_storage_set_critical(&file->storage->storage,
+ "file_try_lock(%s) failed: %m", file->cur_path);
+ }
+#else
ret = file_dotlock_create(&dotlock_set, file->cur_path,
DOTLOCK_CREATE_FLAG_NONBLOCK, &file->lock);
if (ret < 0) {
mail_storage_set_critical(&file->storage->storage,
"file_dotlock_create(%s) failed: %m", file->cur_path);
}
-#else
- ret = file_try_lock(file->fd, file->cur_path, F_WRLCK,
- DBOX_FILE_LOCK_METHOD, &file->lock);
- if (ret < 0) {
- mail_storage_set_critical(&file->storage->storage,
- "file_try_lock(%s) failed: %m", file->cur_path);
- }
#endif
return ret;
}
@@ -321,10 +321,10 @@
i_assert(!file->appending || file->lock == NULL);
if (file->lock != NULL) {
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
+#ifdef DBOX_FILE_LOCK_METHOD_FLOCK
+ file_unlock(&file->lock);
+#else
(void)file_dotlock_delete(&file->lock);
-#else
- file_unlock(&file->lock);
#endif
}
if (file->input != NULL)
diff -r b13146b6a91b -r 4f6fa828d0c9 src/lib-storage/index/dbox-common/dbox-file.h
--- a/src/lib-storage/index/dbox-common/dbox-file.h Mon Apr 26 15:43:01 2010 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-file.h Mon Apr 26 17:46:13 2010 +0300
@@ -23,9 +23,7 @@
same file from multiple mail_storages within same process. that's why we
fallback to dotlocks. */
#ifdef HAVE_FLOCK
-# define DBOX_FILE_LOCK_METHOD FILE_LOCK_METHOD_FLOCK
-#else
-# define DBOX_FILE_LOCK_METHOD FILE_LOCK_METHOD_DOTLOCK
+# define DBOX_FILE_LOCK_METHOD_FLOCK
#endif
struct dbox_file;
@@ -106,10 +104,10 @@
char *primary_path, *alt_path;
int fd;
struct istream *input;
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
+#ifdef DBOX_FILE_LOCK_METHOD_FLOCK
+ struct file_lock *lock;
+#else
struct dotlock *lock;
-#else
- struct file_lock *lock;
#endif
uoff_t cur_offset;
More information about the dovecot-cvs
mailing list