dovecot: Update caching decision for fields even if it doesn't c...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Dec 30 00:27:48 EET 2007
details: http://hg.dovecot.org/dovecot/rev/3cb00348ed06
changeset: 7076:3cb00348ed06
user: Timo Sirainen <tss at iki.fi>
date: Sun Dec 30 00:27:44 2007 +0200
description:
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.
diffstat:
3 files changed, 16 insertions(+), 9 deletions(-)
src/lib-index/mail-cache-decisions.c | 7 +++++--
src/lib-index/mail-cache-lookup.c | 15 +++++++++------
src/lib-index/mail-cache-private.h | 3 ++-
diffs (78 lines):
diff -r c8507f755f0b -r 3cb00348ed06 src/lib-index/mail-cache-decisions.c
--- 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 @@ void mail_cache_decision_state_update(st
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 @@ void mail_cache_decision_state_update(st
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;
}
diff -r c8507f755f0b -r 3cb00348ed06 src/lib-index/mail-cache-lookup.c
--- 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 @@ int mail_cache_lookup_field(struct mail_
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 @@ mail_cache_lookup_headers_real(struct ma
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 @@ mail_cache_lookup_headers_real(struct ma
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);
diff -r c8507f755f0b -r 3cb00348ed06 src/lib-index/mail-cache-private.h
--- 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 @@ int mail_cache_link(struct mail_cache *c
/* 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,
More information about the dovecot-cvs
mailing list