changeset 6360:461ae76c84da HEAD

Replaced MAIL_INDEX_LOCK_SECS usage with cache/index/log specific defines which are common with dotlocks.
author Timo Sirainen <tss@iki.fi>
date Sun, 09 Sep 2007 04:33:45 +0300
parents c54c07f30a97
children 7f6c99dc1f17
files src/lib-index/mail-cache.c src/lib-index/mail-index-lock.c src/lib-index/mail-index-private.h src/lib-index/mail-transaction-log-file.c src/lib-index/mail-transaction-log-private.h src/lib-index/mail-transaction-log.c
diffstat 6 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-cache.c	Sun Sep 09 03:59:09 2007 +0300
+++ b/src/lib-index/mail-cache.c	Sun Sep 09 04:33:45 2007 +0300
@@ -427,7 +427,7 @@
 		i_assert(cache->file_lock == NULL);
 		ret = mail_index_lock_fd(cache->index, cache->filepath,
 					 cache->fd, F_WRLCK,
-					 MAIL_INDEX_LOCK_SECS,
+					 MAIL_CACHE_LOCK_TIMEOUT,
 					 &cache->file_lock);
 	} else {
 		i_assert(cache->dotlock == NULL);
--- a/src/lib-index/mail-index-lock.c	Sun Sep 09 03:59:09 2007 +0300
+++ b/src/lib-index/mail-index-lock.c	Sun Sep 09 04:33:45 2007 +0300
@@ -21,6 +21,8 @@
 #include "nfs-workarounds.h"
 #include "mail-index-private.h"
 
+#define MAIL_INDEX_SHARED_LOCK_TIMEOUT 120
+
 int mail_index_lock_fd(struct mail_index *index, const char *path, int fd,
 		       int lock_type, unsigned int timeout_secs,
 		       struct file_lock **lock_r)
@@ -138,7 +140,8 @@
 {
 	int ret;
 
-	ret = mail_index_lock(index, F_RDLCK, MAIL_INDEX_LOCK_SECS, lock_id_r);
+	ret = mail_index_lock(index, F_RDLCK, MAIL_INDEX_SHARED_LOCK_TIMEOUT,
+			      lock_id_r);
 	if (ret > 0) {
 		mail_index_flush_read_cache(index);
 		return 0;
--- a/src/lib-index/mail-index-private.h	Sun Sep 09 03:59:09 2007 +0300
+++ b/src/lib-index/mail-index-private.h	Sun Sep 09 04:33:45 2007 +0300
@@ -14,8 +14,6 @@
 
 /* How large index files to mmap() instead of reading to memory. */
 #define MAIL_INDEX_MMAP_MIN_SIZE (1024*64)
-/* How many seconds to wait a lock for index file. */
-#define MAIL_INDEX_LOCK_SECS 120
 /* How many times to retry opening index files if read/fstat returns ESTALE.
    This happens with NFS when the file has been deleted (ie. index file was
    rewritten by another computer than us). */
--- a/src/lib-index/mail-transaction-log-file.c	Sun Sep 09 03:59:09 2007 +0300
+++ b/src/lib-index/mail-transaction-log-file.c	Sun Sep 09 04:33:45 2007 +0300
@@ -267,7 +267,7 @@
 
 	i_assert(file->file_lock == NULL);
 	ret = mail_index_lock_fd(file->log->index, file->filepath, file->fd,
-				 F_WRLCK, MAIL_INDEX_LOCK_SECS,
+				 F_WRLCK, MAIL_TRANSCATION_LOG_LOCK_TIMEOUT,
 				 &file->file_lock);
 	if (ret > 0) {
 		file->locked = TRUE;
--- a/src/lib-index/mail-transaction-log-private.h	Sun Sep 09 03:59:09 2007 +0300
+++ b/src/lib-index/mail-transaction-log-private.h	Sun Sep 09 04:33:45 2007 +0300
@@ -4,6 +4,11 @@
 #include "file-dotlock.h"
 #include "mail-transaction-log.h"
 
+/* Synchronization can take a while sometimes, especially when copying lots of
+   mails. */
+#define MAIL_TRANSCATION_LOG_LOCK_TIMEOUT (3*60)
+#define MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT (3*60)
+
 /* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */
 #define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*32)
 /* If log is larger than MAX_SIZE, rotate regardless of the time */
--- a/src/lib-index/mail-transaction-log.c	Sun Sep 09 03:59:09 2007 +0300
+++ b/src/lib-index/mail-transaction-log.c	Sun Sep 09 04:33:45 2007 +0300
@@ -14,10 +14,6 @@
 #include <stdio.h>
 #include <sys/stat.h>
 
-/* this lock should never exist for a long time.. */
-#define LOG_DOTLOCK_TIMEOUT 60
-#define LOG_DOTLOCK_STALE_TIMEOUT 60
-
 #define MAIL_TRANSACTION_LOG_SUFFIX ".log"
 #define LOG_NEW_DOTLOCK_SUFFIX ".newlock"
 
@@ -43,8 +39,9 @@
 	log->index = index;
 
 	log->dotlock_settings.use_excl_lock = index->use_excl_dotlocks;
-	log->dotlock_settings.timeout = LOG_DOTLOCK_TIMEOUT;
-	log->dotlock_settings.stale_timeout = LOG_DOTLOCK_STALE_TIMEOUT;
+	log->dotlock_settings.timeout = MAIL_TRANSCATION_LOG_LOCK_TIMEOUT;
+	log->dotlock_settings.stale_timeout =
+		MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT;
 
 	log->new_dotlock_settings = log->dotlock_settings;
 	log->new_dotlock_settings.lock_suffix = LOG_NEW_DOTLOCK_SUFFIX;