]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mdbox: Recent change enabled dotlocking always, instead of using flock.
authorTimo Sirainen <tss@iki.fi>
Mon, 26 Apr 2010 14:46:13 +0000 (17:46 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 26 Apr 2010 14:46:13 +0000 (17:46 +0300)
--HG--
branch : HEAD

src/lib-storage/index/dbox-common/dbox-file.c
src/lib-storage/index/dbox-common/dbox-file.h

index 40402c5c080cc47af47721d4b64abf1df19bca2a..661653ab9685e57669aacc690605ac34d412b415 100644 (file)
@@ -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,19 +298,19 @@ int dbox_file_try_lock(struct dbox_file *file)
 
        i_assert(file->fd != -1);
 
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
-       ret = file_dotlock_create(&dotlock_set, file->cur_path,
-                                 DOTLOCK_CREATE_FLAG_NONBLOCK, &file->lock);
+#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_dotlock_create(%s) failed: %m", file->cur_path);
+                       "file_try_lock(%s) failed: %m", file->cur_path);
        }
 #else
-       ret = file_try_lock(file->fd, file->cur_path, F_WRLCK,
-                           DBOX_FILE_LOCK_METHOD, &file->lock);
+       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_try_lock(%s) failed: %m", file->cur_path);
+                       "file_dotlock_create(%s) failed: %m", file->cur_path);
        }
 #endif
        return ret;
@@ -321,10 +321,10 @@ void dbox_file_unlock(struct dbox_file *file)
        i_assert(!file->appending || file->lock == NULL);
 
        if (file->lock != NULL) {
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
-               (void)file_dotlock_delete(&file->lock);
-#else
+#ifdef DBOX_FILE_LOCK_METHOD_FLOCK
                file_unlock(&file->lock);
+#else
+               (void)file_dotlock_delete(&file->lock);
 #endif
        }
        if (file->input != NULL)
index 1476a2be030445de420c4bfb3535920480fbe388..77e7ea6d90cf7f50441a540e2c68e53d5b9fcba9 100644 (file)
@@ -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 @@ struct dbox_file {
        char *primary_path, *alt_path;
        int fd;
        struct istream *input;
-#if DBOX_FILE_LOCK_METHOD == FILE_LOCK_METHOD_DOTLOCK
-       struct dotlock *lock;
-#else
+#ifdef DBOX_FILE_LOCK_METHOD_FLOCK
        struct file_lock *lock;
+#else
+       struct dotlock *lock;
 #endif
 
        uoff_t cur_offset;