]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Mail cache: If locking failed, the next time try to lock it only once.
authorTimo Sirainen <tss@iki.fi>
Thu, 11 Sep 2008 14:10:46 +0000 (17:10 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 11 Sep 2008 14:10:46 +0000 (17:10 +0300)
Also increased the first timeout to 10 seconds.

--HG--
branch : HEAD

src/lib-index/mail-cache-private.h
src/lib-index/mail-cache.c

index aa40c86a4534e30f7e9ecb6f95b5d72846576eae..4ea905079b1f74cebe0d0dc3a32005bada23392e 100644 (file)
@@ -36,7 +36,7 @@
 /* When allocating space for transactions, don't use blocks larger than this. */
 #define MAIL_CACHE_MAX_RESERVED_BLOCK_SIZE (1024*512)
 
-#define MAIL_CACHE_LOCK_TIMEOUT 2
+#define MAIL_CACHE_LOCK_TIMEOUT 10
 #define MAIL_CACHE_LOCK_CHANGE_TIMEOUT 300
 
 #define CACHE_RECORD(cache, offset) \
@@ -171,6 +171,7 @@ struct mail_cache {
 
        unsigned int opened:1;
        unsigned int locked:1;
+       unsigned int last_lock_failed:1;
        unsigned int hdr_modified:1;
        unsigned int field_header_write_pending:1;
        unsigned int compressing:1;
index e7fdf585684ed5566f1e1add830d59abfc57dbe5..6eb9ff1ff7f3d8bfcf950dc2fe43f81f25606685 100644 (file)
@@ -464,6 +464,12 @@ static int mail_cache_lock_file(struct mail_cache *cache, bool nonblock)
 {
        int ret;
 
+       if (cache->last_lock_failed) {
+               /* previous locking failed. don't waste time waiting on it
+                  again, just try once to see if it's available now. */
+               nonblock = TRUE;
+       }
+
        if (cache->index->lock_method != FILE_LOCK_METHOD_DOTLOCK) {
                i_assert(cache->file_lock == NULL);
                ret = mail_index_lock_fd(cache->index, cache->filepath,
@@ -483,6 +489,7 @@ static int mail_cache_lock_file(struct mail_cache *cache, bool nonblock)
                                                     "file_dotlock_create()");
                }
        }
+       cache->last_lock_failed = ret <= 0;
 
        /* don't bother warning if locking failed due to a timeout. since cache
           updating isn't all that important we're using a very short timeout