From: Timo Sirainen Date: Mon, 21 Jun 2004 14:20:08 +0000 (+0300) Subject: Disable cache with mmap_disabled=yes, for now. X-Git-Tag: 1.1.alpha1~3886 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba482d3624ca4f1b3d638e6e8470ba5134f21493;p=thirdparty%2Fdovecot%2Fcore.git Disable cache with mmap_disabled=yes, for now. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index badc732170..a0ddd24369 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -513,7 +513,7 @@ int mail_cache_add(struct mail_cache_transaction_ctx *ctx, uint32_t seq, if ((data_size & 3) != 0) memset(buf, 0, 4 - (data_size & 3)); - /* remember the transaction uid range */ + /* remember the transaction sequence range */ if (seq < ctx->first_seq || ctx->first_seq == 0) ctx->first_seq = seq; if (seq > ctx->last_seq) diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index e852abe8ae..e1cc15114d 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -378,7 +378,8 @@ struct mail_cache *mail_cache_open_or_create(struct mail_index *index) cache->fd = -1; cache->split_header_pool = pool_alloconly_create("Headers", 512); - if (mail_cache_open_or_create_file(cache, &hdr) < 0) { + if (index->mmap_disable || + mail_cache_open_or_create_file(cache, &hdr) < 0) { /* failed for some reason - doesn't really matter, just disable caching. */ mail_cache_file_close(cache); @@ -461,9 +462,12 @@ int mail_cache_lock(struct mail_cache *cache, int nonblock) { int ret; - if (cache->locks++ != 0) + if (cache->locks != 0) return 1; + if (cache->disabled) + return 0; + if (nonblock) { ret = file_try_lock(cache->fd, F_WRLCK); if (ret < 0) @@ -484,6 +488,7 @@ int mail_cache_lock(struct mail_cache *cache, int nonblock) mail_cache_unlock(cache); return 0; } + cache->locks++; } return ret; } @@ -508,7 +513,8 @@ int mail_cache_is_locked(struct mail_cache *cache) int mail_cache_need_reset(struct mail_cache *cache, uint32_t *new_file_seq_r) { - if (cache->hdr->file_seq != cache->index->hdr->cache_file_seq) { + if (!cache->disabled && + cache->hdr->file_seq != cache->index->hdr->cache_file_seq) { if (mail_cache_lock(cache, TRUE) == 0) { *new_file_seq_r = cache->hdr->file_seq; return TRUE;