Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6717:02014f5b0068 HEAD
Don't write fields to cache file with last_used=0. If fields were just
added without being used yet, this makes sure that they're not dropped too
early by compression.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 07 Nov 2007 00:40:11 +0200 |
parents | 35bebea1211b |
children | 4e4a5d6bb2cb |
files | src/lib-index/mail-cache-compress.c src/lib-index/mail-cache-fields.c |
diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-compress.c Wed Nov 07 00:24:19 2007 +0200 +++ b/src/lib-index/mail-cache-compress.c Wed Nov 07 00:40:11 2007 +0200 @@ -204,6 +204,14 @@ used fields */ max_drop_time = idx_hdr->day_stamp == 0 ? 0 : idx_hdr->day_stamp - MAIL_CACHE_FIELD_DROP_SECS; + + /* if some fields' "last used" time is zero, they were probably just + added by us. change them to the current time. */ + for (i = 0; i < cache->fields_count; i++) { + if (cache->fields[i].last_used == 0) + cache->fields[i].last_used = ioloop_time; + } + orig_fields_count = cache->fields_count; if (cache->file_fields_count == 0) { /* creating the initial cache file. add all fields. */
--- a/src/lib-index/mail-cache-fields.c Wed Nov 07 00:24:19 2007 +0200 +++ b/src/lib-index/mail-cache-fields.c Wed Nov 07 00:40:11 2007 +0200 @@ -1,6 +1,7 @@ /* Copyright (c) 2004-2007 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "ioloop.h" #include "buffer.h" #include "hash.h" #include "file-cache.h" @@ -490,6 +491,11 @@ memset(&hdr, 0, sizeof(hdr)); hdr.fields_count = cache->file_fields_count; for (i = 0; i < cache->fields_count; i++) { + if (cache->fields[i].last_used == 0) { + /* return newly added fields' last_used as + the current time */ + cache->fields[i].last_used = ioloop_time; + } if (CACHE_FIELD_IS_NEWLY_WANTED(cache, i)) hdr.fields_count++; }