rspamd_upstreams_library_config (worker->srv->cfg, worker->srv->cfg->ups_ctx,
ctx->ev_base, ctx->resolver->r);
- /* Maps events */
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver);
rspamd_symbols_cache_start_refresh (worker->srv->cfg->cache, ctx->ev_base,
worker);
rspamd_stat_init (worker->srv->cfg, ctx->ev_base);
if (worker->index == 0) {
rspamd_worker_init_monitored (worker, ctx->ev_base, ctx->resolver);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, TRUE);
+ }
+ else {
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, FALSE);
}
event_base_loop (ctx->ev_base, 0);
ctx->resolver = dns_resolver_init (worker->srv->logger,
ctx->ev_base,
worker->srv->cfg);
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, 0);
/* Get peer pipe */
memset (&srv_cmd, 0, sizeof (srv_cmd));
* 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;
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;
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;
/* 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;
map = cur->data;
map->ev_base = ev_base;
map->r = resolver;
+ map->active_http = active_http;
rspamd_map_schedule_periodic (map, FALSE, TRUE, FALSE);
/**
* Start watching of maps by adding events to libevent event loop
*/
-void rspamd_map_watch (struct rspamd_config *cfg,
- struct event_base *ev_base,
- struct rspamd_dns_resolver *resolver);
+void rspamd_map_watch (struct rspamd_config *cfg, struct event_base *ev_base,
+ struct rspamd_dns_resolver *resolver, gboolean active_http);
/**
* Remove all maps watched (remove events)
gchar *description;
gchar *name;
guint32 id;
+ /* Should we check HTTP or just load cached data */
+ gboolean active_http;
struct timeval tv;
gdouble poll_timeout;
/* Shared lock for temporary disabling of map reading (e.g. when this map is written by UI) */
}
/* Maps events */
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, 0);
event_base_loop (ctx->ev_base, 0);
rspamd_worker_block_signals ();
ctx->ev_base,
worker->srv->cfg);
double_to_tv (ctx->timeout, &ctx->io_tv);
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, 0);
rspamd_upstreams_library_config (worker->srv->cfg, ctx->cfg->ups_ctx,
ctx->ev_base, ctx->resolver->r);
ctx->resolver = dns_resolver_init (worker->srv->logger,
ctx->ev_base,
worker->srv->cfg);
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, 0);
rspamd_upstreams_library_config (worker->srv->cfg, ctx->cfg->ups_ctx,
ctx->ev_base, ctx->resolver->r);