changeset 11191:4f6fa828d0c9 HEAD

mdbox: Recent change enabled dotlocking always, instead of using flock.
author Timo Sirainen <tss@iki.fi>
date Mon, 26 Apr 2010 17:46:13 +0300
parents b13146b6a91b
children abf262317b2c
files src/lib-storage/index/dbox-common/dbox-file.c src/lib-storage/index/dbox-common/dbox-file.h
diffstat 2 files changed, 16 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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;