From 432718d1dcf1c97c2d5cd3381240ecb9c0ac4e3d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 13 Jun 2018 14:59:21 +0100 Subject: [PATCH] [Fix] Fix HTTP maps updates Issue: #2286 --- src/libutil/map.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libutil/map.c b/src/libutil/map.c index 2873b76f6..f666ad98d 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -344,9 +344,13 @@ rspamd_map_cache_cb (gint fd, short what, gpointer ud) if (cache_cbd->gen != cache_cbd->data->gen) { /* We have another update, so this cache element is obviously expired */ - /* Important: we do not set cache availability to zero here */ + /* + * Important!: we do not set cache availability to zero here, as there + * might be fresh cache + */ + msg_info_map ("cached data is now expired (gen mismatch %L != %L) for %s", + cache_cbd->gen, cache_cbd->data->gen, map->name); MAP_RELEASE (cache_cbd->shm, "rspamd_http_map_cached_cbdata"); - msg_info_map ("cached data is now expired (gen mismatch) for %s", map->name); event_del (&cache_cbd->timeout); g_free (cache_cbd); } @@ -447,6 +451,9 @@ http_map_finish (struct rspamd_http_connection *conn, cbd->periodic->need_modify = TRUE; /* Reset the whole chain */ cbd->periodic->cur_backend = 0; + /* Reset cache, old cached data will be cleaned on timeout */ + g_atomic_int_set (&map->cache->available, 0); + rspamd_map_periodic_callback (-1, EV_TIMEOUT, cbd->periodic); MAP_RELEASE (cbd, "http_callback_data"); -- 2.39.5