dovecot: Replaced MAIL_INDEX_LOCK_SECS usage with cache/index/lo...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 9 04:33:53 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/461ae76c84da
changeset: 6360:461ae76c84da
user: Timo Sirainen <tss at iki.fi>
date: Sun Sep 09 04:33:45 2007 +0300
description:
Replaced MAIL_INDEX_LOCK_SECS usage with cache/index/log specific defines
which are common with dotlocks.
diffstat:
6 files changed, 14 insertions(+), 11 deletions(-)
src/lib-index/mail-cache.c | 2 +-
src/lib-index/mail-index-lock.c | 5 ++++-
src/lib-index/mail-index-private.h | 2 --
src/lib-index/mail-transaction-log-file.c | 2 +-
src/lib-index/mail-transaction-log-private.h | 5 +++++
src/lib-index/mail-transaction-log.c | 9 +++------
diffs (99 lines):
diff -r c54c07f30a97 -r 461ae76c84da src/lib-index/mail-cache.c
--- 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 @@ static int mail_cache_lock_file(struct m
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);
diff -r c54c07f30a97 -r 461ae76c84da src/lib-index/mail-index-lock.c
--- 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
@@ -20,6 +20,8 @@
#include "lib.h"
#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,
@@ -138,7 +140,8 @@ int mail_index_lock_shared(struct mail_i
{
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;
diff -r c54c07f30a97 -r 461ae76c84da src/lib-index/mail-index-private.h
--- 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 @@ struct mail_index_sync_map_ctx;
/* 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). */
diff -r c54c07f30a97 -r 461ae76c84da src/lib-index/mail-transaction-log-file.c
--- 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 @@ int mail_transaction_log_file_lock(struc
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;
diff -r c54c07f30a97 -r 461ae76c84da src/lib-index/mail-transaction-log-private.h
--- 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
@@ -3,6 +3,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)
diff -r c54c07f30a97 -r 461ae76c84da src/lib-index/mail-transaction-log.c
--- 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 @@ mail_transaction_log_alloc(struct mail_i
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;
More information about the dovecot-cvs
mailing list