diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-07 18:54:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-07 18:54:50 +0100 |
commit | 8c673af47019c362d94910e9e69b46d098b9cceb (patch) | |
tree | 0b55ca70fd1e31b538f4ead8b94ea65e2b18b88b /src/libutil/map.c | |
parent | 4b417747c442cd987a3036176767654a643a7e87 (diff) | |
download | rspamd-8c673af47019c362d94910e9e69b46d098b9cceb.tar.gz rspamd-8c673af47019c362d94910e9e69b46d098b9cceb.zip |
[Feature] Improve maps checking frequency
Diffstat (limited to 'src/libutil/map.c')
-rw-r--r-- | src/libutil/map.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c index 4402a7910..0019aaa90 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -1061,8 +1061,10 @@ rspamd_map_read_cached (struct rspamd_map *map, struct rspamd_map_backend *bk, * Async HTTP callback */ static void -rspamd_map_common_http_callback (struct rspamd_map *map, struct rspamd_map_backend *bk, - struct map_periodic_cbdata *periodic, gboolean check) +rspamd_map_common_http_callback (struct rspamd_map *map, + struct rspamd_map_backend *bk, + struct map_periodic_cbdata *periodic, + gboolean check) { struct http_map_data *data; struct http_callback_data *cbd; @@ -1080,9 +1082,15 @@ rspamd_map_common_http_callback (struct rspamd_map *map, struct rspamd_map_backe rspamd_map_periodic_callback (-1, EV_TIMEOUT, periodic); } else { - /* Switch to the next backend */ - periodic->cur_backend ++; - rspamd_map_periodic_callback (-1, EV_TIMEOUT, periodic); + if (map->active_http) { + /* Check even if there is a cached version */ + goto check; + } + else { + /* Switch to the next backend */ + periodic->cur_backend++; + rspamd_map_periodic_callback (-1, EV_TIMEOUT, periodic); + } } return; @@ -1096,7 +1104,15 @@ rspamd_map_common_http_callback (struct rspamd_map *map, struct rspamd_map_backe return; } } + else if (!map->active_http) { + /* Switch to the next backend */ + periodic->cur_backend ++; + rspamd_map_periodic_callback (-1, EV_TIMEOUT, periodic); + + return; + } +check: cbd = g_slice_alloc0 (sizeof (struct http_callback_data)); cbd->ev_base = map->ev_base; @@ -1384,9 +1400,8 @@ rspamd_map_periodic_callback (gint fd, short what, void *ud) /* Start watching event for all maps */ void -rspamd_map_watch (struct rspamd_config *cfg, - struct event_base *ev_base, - struct rspamd_dns_resolver *resolver) +rspamd_map_watch (struct rspamd_config *cfg, struct event_base *ev_base, + struct rspamd_dns_resolver *resolver, gboolean active_http) { GList *cur = cfg->maps; struct rspamd_map *map; @@ -1396,6 +1411,7 @@ rspamd_map_watch (struct rspamd_config *cfg, map = cur->data; map->ev_base = ev_base; map->r = resolver; + map->active_http = active_http; rspamd_map_schedule_periodic (map, FALSE, TRUE, FALSE); |