dovecot-2.2: lib-index: Support a small in-memory cache even wit...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Nov 16 19:36:52 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/03bf99704fe5
changeset: 16956:03bf99704fe5
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 16 19:34:57 2013 +0200
description:
lib-index: Support a small in-memory cache even with INDEX=MEMORY
diffstat:
src/lib-index/mail-cache-lookup.c | 8 +++++---
src/lib-index/mail-cache-transaction.c | 22 ++++++++++++++++++++--
2 files changed, 25 insertions(+), 5 deletions(-)
diffs (63 lines):
diff -r c7e55077ea4e -r 03bf99704fe5 src/lib-index/mail-cache-lookup.c
--- a/src/lib-index/mail-cache-lookup.c Sat Nov 16 19:20:10 2013 +0200
+++ b/src/lib-index/mail-cache-lookup.c Sat Nov 16 19:34:57 2013 +0200
@@ -191,15 +191,17 @@
if (ctx->offset == 0) {
/* end of this record list. check newly appended data. */
if (view->trans_seq1 > ctx->seq ||
- view->trans_seq2 < ctx->seq ||
- MAIL_CACHE_IS_UNUSABLE(view->cache))
+ view->trans_seq2 < ctx->seq)
return 0;
- /* check data still in memory */
+ /* check data still in memory. this works for recent mails
+ even with INDEX=MEMORY */
if (!ctx->memory_appends_checked) {
if (mail_cache_lookup_iter_transaction(ctx))
return 1;
ctx->memory_appends_checked = TRUE;
}
+ if (MAIL_CACHE_IS_UNUSABLE(view->cache))
+ return 0;
/* check data already written to cache file */
if (ctx->disk_appends_checked ||
diff -r c7e55077ea4e -r 03bf99704fe5 src/lib-index/mail-cache-transaction.c
--- a/src/lib-index/mail-cache-transaction.c Sat Nov 16 19:20:10 2013 +0200
+++ b/src/lib-index/mail-cache-transaction.c Sat Nov 16 19:34:57 2013 +0200
@@ -592,6 +592,20 @@
struct mail_cache *cache = ctx->cache;
int ret;
+ if (MAIL_INDEX_IS_IN_MEMORY(cache->index)) {
+ if (cache->file_fields_count <= field_idx) {
+ cache->file_field_map =
+ i_realloc(cache->file_field_map,
+ cache->file_fields_count *
+ sizeof(unsigned int),
+ (field_idx+1) * sizeof(unsigned int));
+ cache->file_fields_count = field_idx+1;
+ }
+ cache->file_field_map[field_idx] = field_idx;
+ cache->field_file_map[field_idx] = field_idx;
+ return 0;
+ }
+
if (mail_cache_transaction_lock(ctx) <= 0) {
if (MAIL_CACHE_IS_UNUSABLE(cache))
return -1;
@@ -679,8 +693,12 @@
if (ret < 0)
return;
- if (ctx->cache_file_seq == 0)
- ctx->cache_file_seq = ctx->cache->hdr->file_seq;
+ if (ctx->cache_file_seq == 0) {
+ if (MAIL_INDEX_IS_IN_MEMORY(ctx->cache->index))
+ ctx->cache_file_seq = 1;
+ else
+ ctx->cache_file_seq = ctx->cache->hdr->file_seq;
+ }
file_field = ctx->cache->field_file_map[field_idx];
i_assert(file_field != (uint32_t)-1);
More information about the dovecot-cvs
mailing list