Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7076:3cb00348ed06 HEAD
Update caching decision for fields even if it doesn't currently exist in the
cache file. If the field is added later within the session, the decision and
last_used field will be correct.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 30 Dec 2007 00:27:44 +0200 |
parents | c8507f755f0b |
children | aa9a4d419905 |
files | src/lib-index/mail-cache-decisions.c src/lib-index/mail-cache-lookup.c src/lib-index/mail-cache-private.h |
diffstat | 3 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-decisions.c Sun Dec 30 00:25:36 2007 +0200 +++ b/src/lib-index/mail-cache-decisions.c Sun Dec 30 00:27:44 2007 +0200 @@ -85,7 +85,8 @@ if (ioloop_time - cache->fields[field].last_used > 3600*24) { /* update last_used about once a day */ cache->fields[field].last_used = (uint32_t)ioloop_time; - cache->field_header_write_pending = TRUE; + if (cache->field_file_map[field] != (uint32_t)-1) + cache->field_header_write_pending = TRUE; } if (cache->fields[field].field.decision != MAIL_CACHE_DECISION_TEMP) { @@ -107,7 +108,9 @@ drop back to TEMP within few months. */ cache->fields[field].field.decision = MAIL_CACHE_DECISION_YES; cache->fields[field].decision_dirty = TRUE; - cache->field_header_write_pending = TRUE; + + if (cache->field_file_map[field] != (uint32_t)-1) + cache->field_header_write_pending = TRUE; } else { cache->fields[field].uid_highwater = uid; }
--- a/src/lib-index/mail-cache-lookup.c Sun Dec 30 00:25:36 2007 +0200 +++ b/src/lib-index/mail-cache-lookup.c Sun Dec 30 00:27:44 2007 +0200 @@ -340,11 +340,12 @@ struct mail_cache_iterate_field field; int ret; - if ((ret = mail_cache_field_exists(view, seq, field_idx)) <= 0) + ret = mail_cache_field_exists(view, seq, field_idx); + mail_cache_decision_state_update(view, seq, field_idx); + if (ret <= 0) return ret; + /* the field should exist */ - mail_cache_decision_state_update(view, seq, field_idx); - mail_cache_lookup_iter_init(view, seq, &iter); field_def = &view->cache->fields[field_idx].field; if (field_def->type == MAIL_CACHE_FIELD_BITMASK) { @@ -445,6 +446,11 @@ if (!view->cache->opened) (void)mail_cache_open_and_verify(view->cache); + /* update the decision state regardless of whether the fields + actually exist or not. */ + for (i = 0; i < fields_count; i++) + mail_cache_decision_state_update(view, seq, field_idxs[i]); + /* mark all the fields we want to find. */ buf = buffer_create_dynamic(pool_datastack_create(), 32); for (i = 0; i < fields_count; i++) { @@ -483,9 +489,6 @@ return 0; } - for (i = 0; i < fields_count; i++) - mail_cache_decision_state_update(view, seq, field_idxs[i]); - /* we need to return headers in the order they existed originally. we can do this by sorting the messages by their line numbers. */ lines = array_get_modifiable(&ctx.lines, &count);
--- a/src/lib-index/mail-cache-private.h Sun Dec 30 00:25:36 2007 +0200 +++ b/src/lib-index/mail-cache-private.h Sun Dec 30 00:27:44 2007 +0200 @@ -254,7 +254,8 @@ /* Mark record in given offset to be deleted. */ int mail_cache_delete(struct mail_cache *cache, uint32_t offset); -/* Notify the decision handling code that field was looked up for seq */ +/* Notify the decision handling code that field was looked up for seq. + This should be called even for fields that aren't currently in cache file */ void mail_cache_decision_state_update(struct mail_cache_view *view, uint32_t seq, unsigned int field); void mail_cache_decision_add(struct mail_cache_view *view, uint32_t seq,