]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to limit maps per specific worker
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Nov 2019 15:30:12 +0000 (15:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Nov 2019 15:30:30 +0000 (15:30 +0000)
16 files changed:
src/controller.c
src/fuzzy_storage.c
src/libserver/cfg_file.h
src/libserver/cfg_utils.c
src/libserver/dynamic_cfg.c
src/libserver/worker_util.c
src/libutil/logger.c
src/libutil/map.c
src/libutil/map.h
src/libutil/util.c
src/lua/lua_map.c
src/plugins/dkim_check.c
src/plugins/fuzzy_check.c
src/plugins/spf.c
src/rspamd_proxy.c
src/worker.c

index 1eb088d903bec295156bb6c965f282f4a05baad0..2ab796791552dcd24dd0bd8b7fa0e36201c73c17 100644 (file)
@@ -3513,7 +3513,9 @@ start_controller_worker (struct rspamd_worker *worker)
        if (ctx->secure_ip != NULL) {
                rspamd_config_radix_from_ucl (ctx->cfg, ctx->secure_ip,
                                "Allow unauthenticated requests from these addresses",
-                               &ctx->secure_map, NULL);
+                               &ctx->secure_map,
+                               NULL,
+                               worker);
        }
 
        ctx->lang_det = ctx->cfg->lang_det;
index 94bbc64849f21f46251a87420cf93743001ae8cf..04acc6ba50d9cabd6e1ccc746fc3185b959093b4 100644 (file)
@@ -1975,7 +1975,7 @@ start_fuzzy (struct rspamd_worker *worker)
        if (ctx->update_map != NULL) {
                rspamd_config_radix_from_ucl (worker->srv->cfg, ctx->update_map,
                                "Allow fuzzy updates from specified addresses",
-                               &ctx->update_ips, NULL);
+                               &ctx->update_ips, NULL, worker);
        }
 
        if (ctx->skip_map != NULL) {
@@ -1986,7 +1986,8 @@ start_fuzzy (struct rspamd_worker *worker)
                                rspamd_kv_list_read,
                                rspamd_kv_list_fin,
                                rspamd_kv_list_dtor,
-                               (void **)&ctx->skip_hashes)) == NULL) {
+                               (void **)&ctx->skip_hashes,
+                               worker)) == NULL) {
                        msg_warn_config ("cannot load hashes list from %s",
                                        ucl_object_tostring (ctx->skip_map));
                }
@@ -1998,14 +1999,18 @@ start_fuzzy (struct rspamd_worker *worker)
        if (ctx->blocked_map != NULL) {
                rspamd_config_radix_from_ucl (worker->srv->cfg, ctx->blocked_map,
                                "Block fuzzy requests from the specific IPs",
-                               &ctx->blocked_ips, NULL);
+                               &ctx->blocked_ips,
+                               NULL,
+                               worker);
        }
 
        /* Create radix trees */
        if (ctx->ratelimit_whitelist_map != NULL) {
                rspamd_config_radix_from_ucl (worker->srv->cfg, ctx->ratelimit_whitelist_map,
                                "Skip ratelimits from specific ip addresses/networks",
-                               &ctx->ratelimit_whitelist, NULL);
+                               &ctx->ratelimit_whitelist,
+                               NULL,
+                               worker);
        }
 
        /* Ratelimits */
@@ -2019,7 +2024,8 @@ start_fuzzy (struct rspamd_worker *worker)
        ctx->resolver = rspamd_dns_resolver_init (worker->srv->logger,
                        ctx->event_loop,
                        worker->srv->cfg);
-       rspamd_map_watch (worker->srv->cfg, ctx->event_loop, ctx->resolver, worker, 0);
+       rspamd_map_watch (worker->srv->cfg, ctx->event_loop,
+                       ctx->resolver, worker, RSPAMD_MAP_WATCH_WORKER);
 
        /* Get peer pipe */
        memset (&srv_cmd, 0, sizeof (srv_cmd));
index e604fe43a46c02a8cbc847b5bee0d358cf72ec0e..fbddd90963a8c86be05b1083407e0769a1c40024 100644 (file)
@@ -758,7 +758,8 @@ gboolean rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
                                                                           const ucl_object_t *obj,
                                                                           const gchar *description,
                                                                           struct rspamd_radix_map_helper **target,
-                                                                          GError **err);
+                                                                          GError **err,
+                                                                          struct rspamd_worker *worker);
 
 /**
  * Adds new settings id to be preprocessed
index ba009cc8184621376e2d7b92f2c19e4153ce6957..857f7a0ac5c9c8ee9884221bf2433832ce31ba2f 100644 (file)
@@ -1149,7 +1149,8 @@ rspamd_include_map_handler (const guchar *data, gsize len,
                           rspamd_ucl_read_cb,
                           rspamd_ucl_fin_cb,
                           rspamd_ucl_dtor_cb,
-                          (void **)pcbdata) != NULL;
+                          (void **)pcbdata,
+                          NULL) != NULL;
 }
 
 /*
@@ -2180,10 +2181,11 @@ rspamd_config_get_action_by_type (struct rspamd_config *cfg,
 
 gboolean
 rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
-               const ucl_object_t *obj,
-               const gchar *description,
-               struct rspamd_radix_map_helper **target,
-               GError **err)
+                                                         const ucl_object_t *obj,
+                                                         const gchar *description,
+                                                         struct rspamd_radix_map_helper **target,
+                                                         GError **err,
+                                                         struct rspamd_worker *worker)
 {
        ucl_type_t type;
        ucl_object_iter_t it = NULL;
@@ -2207,8 +2209,10 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
                                                rspamd_radix_read,
                                                rspamd_radix_fin,
                                                rspamd_radix_dtor,
-                                               (void **)target) == NULL) {
-                                       g_set_error (err, g_quark_from_static_string ("rspamd-config"),
+                                               (void **)target,
+                                               worker) == NULL) {
+                                       g_set_error (err,
+                                                       g_quark_from_static_string ("rspamd-config"),
                                                        EINVAL, "bad map definition %s for %s", str,
                                                        ucl_object_key (obj));
                                        return FALSE;
@@ -2232,8 +2236,10 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
                                        rspamd_radix_read,
                                        rspamd_radix_fin,
                                        rspamd_radix_dtor,
-                                       (void **)target) == NULL) {
-                               g_set_error (err, g_quark_from_static_string ("rspamd-config"),
+                                       (void **)target,
+                                       worker) == NULL) {
+                               g_set_error (err,
+                                               g_quark_from_static_string ("rspamd-config"),
                                                EINVAL, "bad map object for %s", ucl_object_key (obj));
                                return FALSE;
                        }
index 45c6838ecd1b3d6998b21d919d4d022bb536ffb7..a39778ec20a66913406b55e8722b4f98ae5d6760 100644 (file)
@@ -283,7 +283,7 @@ init_dynamic_config (struct rspamd_config *cfg)
                        json_config_read_cb,
                        json_config_fin_cb,
                        json_config_dtor_cb,
-                       (void **)pjb)) {
+                       (void **)pjb, NULL)) {
                msg_err ("cannot add map for configuration %s", cfg->dynamic_conf);
        }
 }
index 08933060c82dc0df1d7bd4640847d49246c077c8..362d64bc5741db9d1c7086bce05388f6f0d817f0 100644 (file)
@@ -1955,7 +1955,8 @@ rspamd_worker_init_controller (struct rspamd_worker *worker,
                ev_timer_start (ctx->event_loop, &cbd.save_stats_event);
 
                rspamd_map_watch (worker->srv->cfg, ctx->event_loop,
-                               ctx->resolver, worker, TRUE);
+                               ctx->resolver, worker,
+                               RSPAMD_MAP_WATCH_PRIMARY_CONTROLLER);
 
                if (prrd != NULL) {
                        if (ctx->cfg->rrd_file && worker->index == 0) {
@@ -1992,6 +1993,6 @@ rspamd_worker_init_controller (struct rspamd_worker *worker,
        }
        else {
                rspamd_map_watch (worker->srv->cfg, ctx->event_loop,
-                               ctx->resolver, worker, FALSE);
+                               ctx->resolver, worker, RSPAMD_MAP_WATCH_SCANNER);
        }
 }
\ No newline at end of file
index 31d018533999e33fa998f05e6e4e3101cbf939a9..193dd4fce7b4c36d92df0b3aac8067077eb88b49 100644 (file)
@@ -579,7 +579,9 @@ rspamd_set_logger (struct rspamd_config *cfg,
                rspamd_config_radix_from_ucl (cfg,
                                cfg->debug_ip_map,
                                "IP addresses for which debug logs are enabled",
-                               &logger->debug_ip, NULL);
+                               &logger->debug_ip,
+                               NULL,
+                               NULL);
        }
        else if (logger->debug_ip) {
                rspamd_map_helper_destroy_radix (logger->debug_ip);
index d8c990a768538a3b4d0eac0108129a21f4f008d8..6fe2a80cae29eb94df4f3feb185a71fe3fc8da3e 100644 (file)
@@ -1985,22 +1985,40 @@ rspamd_map_watch (struct rspamd_config *cfg,
                                  struct ev_loop *event_loop,
                                  struct rspamd_dns_resolver *resolver,
                                  struct rspamd_worker *worker,
-                                 gboolean active_http)
+                                 enum rspamd_map_watch_type how)
 {
        GList *cur = cfg->maps;
        struct rspamd_map *map;
        struct rspamd_map_backend *bk;
        guint i;
 
+       g_assert (how > RSPAMD_MAP_WATCH_MIN && how < RSPAMD_MAP_WATCH_MAX);
+
        /* First of all do synced read of data */
        while (cur) {
                map = cur->data;
                map->event_loop = event_loop;
                map->r = resolver;
-               map->wrk = worker;
 
-               if (active_http) {
-                       map->active_http = active_http;
+               if (map->wrk == NULL && how != RSPAMD_MAP_WATCH_WORKER) {
+                       /* Generic scanner map */
+                       map->wrk = worker;
+
+                       if (how == RSPAMD_MAP_WATCH_PRIMARY_CONTROLLER) {
+                               map->active_http = TRUE;
+                       }
+                       else {
+                               map->active_http = FALSE;
+                       }
+               }
+               else if (map->wrk != NULL && map->wrk == worker) {
+                       /* Map is bound to a specific worker */
+                       map->active_http = TRUE;
+               }
+               else {
+                       /* Skip map for this worker as irrelevant */
+                       cur = g_list_next (cur);
+                       continue;
                }
 
                if (!map->active_http) {
@@ -2590,7 +2608,8 @@ rspamd_map_add (struct rspamd_config *cfg,
                                map_cb_t read_callback,
                                map_fin_cb_t fin_callback,
                                map_dtor_t dtor,
-                               void **user_data)
+                               void **user_data,
+                               struct rspamd_worker *worker)
 {
        struct rspamd_map *map;
        struct rspamd_map_backend *bk;
@@ -2617,6 +2636,7 @@ rspamd_map_add (struct rspamd_config *cfg,
        map->locked =
                rspamd_mempool_alloc0_shared (cfg->cfg_pool, sizeof (gint));
        map->backends = g_ptr_array_sized_new (1);
+       map->wrk = worker;
        rspamd_mempool_add_destructor (cfg->cfg_pool, rspamd_ptr_array_free_hard,
                        map->backends);
        g_ptr_array_add (map->backends, bk);
@@ -2663,7 +2683,8 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
                                                 map_cb_t read_callback,
                                                 map_fin_cb_t fin_callback,
                                                 map_dtor_t dtor,
-                                                void **user_data)
+                                                void **user_data,
+                                                struct rspamd_worker *worker)
 {
        ucl_object_iter_t it = NULL;
        const ucl_object_t *cur, *elt;
@@ -2676,7 +2697,7 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
        if (ucl_object_type (obj) == UCL_STRING) {
                /* Just a plain string */
                return rspamd_map_add (cfg, ucl_object_tostring (obj), description,
-                               read_callback, fin_callback, dtor, user_data);
+                               read_callback, fin_callback, dtor, user_data, worker);
        }
 
        map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_map));
@@ -2689,6 +2710,7 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
        map->locked =
                        rspamd_mempool_alloc0_shared (cfg->cfg_pool, sizeof (gint));
        map->backends = g_ptr_array_new ();
+       map->wrk = worker;
        rspamd_mempool_add_destructor (cfg->cfg_pool, rspamd_ptr_array_free_hard,
                        map->backends);
        map->poll_timeout = cfg->map_timeout;
index 9e09ab8fed07ca471598b94e705bcb78deba353e..ce49bacbbd430ef60eea8d4d17caf69751bee902 100644 (file)
@@ -70,7 +70,8 @@ struct rspamd_map *rspamd_map_add (struct rspamd_config *cfg,
                                                                   map_cb_t read_callback,
                                                                   map_fin_cb_t fin_callback,
                                                                   map_dtor_t dtor,
-                                                                  void **user_data);
+                                                                  void **user_data,
+                                                                  struct rspamd_worker *worker);
 
 /**
  * Add map from ucl
@@ -81,7 +82,16 @@ struct rspamd_map *rspamd_map_add_from_ucl (struct rspamd_config *cfg,
                                                                                        map_cb_t read_callback,
                                                                                        map_fin_cb_t fin_callback,
                                                                                        map_dtor_t dtor,
-                                                                                       void **user_data);
+                                                                                       void **user_data,
+                                                                                       struct rspamd_worker *worker);
+
+enum rspamd_map_watch_type {
+       RSPAMD_MAP_WATCH_MIN = 9,
+       RSPAMD_MAP_WATCH_PRIMARY_CONTROLLER,
+       RSPAMD_MAP_WATCH_SCANNER,
+       RSPAMD_MAP_WATCH_WORKER,
+       RSPAMD_MAP_WATCH_MAX
+};
 
 /**
  * Start watching of maps by adding events to libevent event loop
@@ -90,7 +100,7 @@ void rspamd_map_watch (struct rspamd_config *cfg,
                                           struct ev_loop *event_loop,
                                           struct rspamd_dns_resolver *resolver,
                                           struct rspamd_worker *worker,
-                                          gboolean active_http);
+                                          enum rspamd_map_watch_type how);
 
 /**
  * Preloads maps where all backends are file
index 5ada3a27ebb87180c498e2a9b437787317cd1538..26410137675d0e97ec5d2d7131a0f1564a5904b7 100644 (file)
@@ -2432,7 +2432,9 @@ rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
                if (cfg->local_addrs) {
                        rspamd_config_radix_from_ucl (cfg, cfg->local_addrs,
                                        "Local addresses",
-                                       ctx->local_addrs, NULL);
+                                       ctx->local_addrs,
+                                       NULL,
+                                       NULL);
                }
 
                if (cfg->ssl_ca_path) {
index bead7ae4abb567e7540760f3b698a4fa294c9561..13674e6b12ad37629746d052e3ff0b28ec13b5b3 100644 (file)
@@ -161,7 +161,8 @@ lua_config_add_radix_map (lua_State *L)
                                rspamd_radix_read,
                                rspamd_radix_fin,
                                rspamd_radix_dtor,
-                               (void **)&map->data.radix)) == NULL) {
+                               (void **)&map->data.radix,
+                               NULL)) == NULL) {
                        msg_warn_config ("invalid radix map %s", map_line);
                        lua_pushnil (L);
 
@@ -218,7 +219,8 @@ lua_config_radix_from_config (lua_State *L)
                                        rspamd_radix_read,
                                        rspamd_radix_fin,
                                        rspamd_radix_dtor,
-                                       (void **)&map->data.radix)) == NULL) {
+                                       (void **)&map->data.radix,
+                                       NULL)) == NULL) {
                                msg_err_config ("invalid radix map static");
                                lua_pushnil (L);
                                ucl_object_unref (fake_obj);
@@ -279,7 +281,8 @@ lua_config_radix_from_ucl (lua_State *L)
                                rspamd_radix_read,
                                rspamd_radix_fin,
                                rspamd_radix_dtor,
-                               (void **)&map->data.radix)) == NULL) {
+                               (void **)&map->data.radix,
+                               NULL)) == NULL) {
                        msg_err_config ("invalid radix map static");
                        lua_pushnil (L);
                        ucl_object_unref (fake_obj);
@@ -324,7 +327,8 @@ lua_config_add_hash_map (lua_State *L)
                                rspamd_kv_list_read,
                                rspamd_kv_list_fin,
                                rspamd_kv_list_dtor,
-                               (void **)&map->data.hash)) == NULL) {
+                               (void **)&map->data.hash,
+                               NULL)) == NULL) {
                        msg_warn_config ("invalid set map %s", map_line);
                        lua_pushnil (L);
                        return 1;
@@ -364,7 +368,8 @@ lua_config_add_kv_map (lua_State *L)
                                rspamd_kv_list_read,
                                rspamd_kv_list_fin,
                                rspamd_kv_list_dtor,
-                               (void **)&map->data.hash)) == NULL) {
+                               (void **)&map->data.hash,
+                               NULL)) == NULL) {
                        msg_warn_config ("invalid hash map %s", map_line);
                        lua_pushnil (L);
 
@@ -529,7 +534,8 @@ lua_config_add_map (lua_State *L)
                                        lua_map_read,
                                        lua_map_fin,
                                        lua_map_dtor,
-                                       (void **)&map->data.cbdata)) == NULL) {
+                                       (void **)&map->data.cbdata,
+                                       NULL)) == NULL) {
 
                                if (cbidx != -1) {
                                        luaL_unref (L, LUA_REGISTRYINDEX, cbidx);
@@ -554,7 +560,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_kv_list_read,
                                        rspamd_kv_list_fin,
                                        rspamd_kv_list_dtor,
-                                       (void **)&map->data.hash)) == NULL) {
+                                       (void **)&map->data.hash,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
@@ -571,7 +578,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_kv_list_read,
                                        rspamd_kv_list_fin,
                                        rspamd_kv_list_dtor,
-                                       (void **)&map->data.hash)) == NULL) {
+                                       (void **)&map->data.hash,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
@@ -588,7 +596,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_radix_read,
                                        rspamd_radix_fin,
                                        rspamd_radix_dtor,
-                                       (void **)&map->data.radix)) == NULL) {
+                                       (void **)&map->data.radix,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
@@ -605,7 +614,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_regexp_list_read_single,
                                        rspamd_regexp_list_fin,
                                        rspamd_regexp_list_dtor,
-                                       (void **) &map->data.re_map)) == NULL) {
+                                       (void **) &map->data.re_map,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
@@ -622,7 +632,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_regexp_list_read_multiple,
                                        rspamd_regexp_list_fin,
                                        rspamd_regexp_list_dtor,
-                                       (void **) &map->data.re_map)) == NULL) {
+                                       (void **) &map->data.re_map,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
@@ -639,7 +650,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_glob_list_read_single,
                                        rspamd_regexp_list_fin,
                                        rspamd_regexp_list_dtor,
-                                       (void **) &map->data.re_map)) == NULL) {
+                                       (void **) &map->data.re_map,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
@@ -656,7 +668,8 @@ lua_config_add_map (lua_State *L)
                                        rspamd_glob_list_read_multiple,
                                        rspamd_regexp_list_fin,
                                        rspamd_regexp_list_dtor,
-                                       (void **) &map->data.re_map)) == NULL) {
+                                       (void **) &map->data.re_map,
+                                       NULL)) == NULL) {
                                lua_pushnil (L);
                                ucl_object_unref (map_obj);
 
index ebe2292a1c4c3ed3dc7e05de5169162ea1201bce..3a88d9bb6d8c73afea03b75b5e5e8e2cae024224 100644 (file)
@@ -435,7 +435,7 @@ dkim_module_config (struct rspamd_config *cfg)
                rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) {
 
                rspamd_config_radix_from_ucl (cfg, value, "DKIM whitelist",
-                               &dkim_module_ctx->whitelist_ip, NULL);
+                               &dkim_module_ctx->whitelist_ip, NULL, NULL);
        }
 
        if ((value =
@@ -445,7 +445,8 @@ dkim_module_config (struct rspamd_config *cfg)
                                rspamd_kv_list_read,
                                rspamd_kv_list_fin,
                                rspamd_kv_list_dtor,
-                               (void **)&dkim_module_ctx->dkim_domains)) {
+                               (void **)&dkim_module_ctx->dkim_domains,
+                               NULL)) {
                        msg_warn_config ("cannot load dkim domains list from %s",
                                ucl_object_tostring (value));
                }
@@ -461,7 +462,8 @@ dkim_module_config (struct rspamd_config *cfg)
                                rspamd_kv_list_read,
                                rspamd_kv_list_fin,
                                rspamd_kv_list_dtor,
-                               (void **)&dkim_module_ctx->dkim_domains)) {
+                               (void **)&dkim_module_ctx->dkim_domains,
+                               NULL)) {
                        msg_warn_config ("cannot load dkim domains list from %s",
                                        ucl_object_tostring (value));
                }
index 3162c1f0e0917a2119b0054f10e031568837c7bb..5c399455970e8f9d558f43c6f26c64f06ccd2da9 100644 (file)
@@ -359,7 +359,8 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj,
                                rspamd_kv_list_read,
                                rspamd_kv_list_fin,
                                rspamd_kv_list_dtor,
-                               (void **)&rule->skip_map);
+                               (void **)&rule->skip_map,
+                               NULL);
        }
 
        if ((value = ucl_object_lookup (obj, "headers")) != NULL) {
@@ -1042,7 +1043,9 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
                rspamd_config_get_module_opt (cfg, "fuzzy_check",
                "whitelist")) != NULL) {
                rspamd_config_radix_from_ucl (cfg, value, "Fuzzy whitelist",
-                               &fuzzy_module_ctx->whitelist, NULL);
+                               &fuzzy_module_ctx->whitelist,
+                               NULL,
+                               NULL);
        }
        else {
                fuzzy_module_ctx->whitelist = NULL;
index 6f120786c61f0ac9fda6206c1846efadda1ce5e9..cc52fbd0bccf1d46efa1f88015a9ff71f57145bb 100644 (file)
@@ -335,7 +335,7 @@ spf_module_config (struct rspamd_config *cfg)
                rspamd_config_get_module_opt (cfg, "spf", "whitelist")) != NULL) {
 
                rspamd_config_radix_from_ucl (cfg, value, "SPF whitelist",
-                               &spf_module_ctx->whitelist_ip, NULL);
+                               &spf_module_ctx->whitelist_ip, NULL, NULL);
        }
 
        cb_id = rspamd_symcache_add_symbol (cfg->cache,
index 737fff608184bd2f7401826c955c68dccd972235..ae51e3e5bff2b587cce4fabe8850d228b167a7b0 100644 (file)
@@ -2297,8 +2297,14 @@ start_rspamd_proxy (struct rspamd_worker *worker)
                rspamd_worker_init_controller (worker, NULL);
        }
        else {
-               rspamd_map_watch (worker->srv->cfg, ctx->event_loop, ctx->resolver,
-                               worker, 0);
+               if (ctx->has_self_scan) {
+                       rspamd_map_watch (worker->srv->cfg, ctx->event_loop, ctx->resolver,
+                                       worker, RSPAMD_MAP_WATCH_SCANNER);
+               }
+               else {
+                       rspamd_map_watch (worker->srv->cfg, ctx->event_loop, ctx->resolver,
+                                       worker, RSPAMD_MAP_WATCH_WORKER);
+               }
        }
 
        rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->event_loop,
index 4279aa82cf2e588f9148ff35df66f06225ea0946..b20800a601b94b34fff7f3a2a10d2b7f84f70aff 100644 (file)
@@ -552,7 +552,7 @@ start_worker (struct rspamd_worker *worker)
        }
        else {
                rspamd_map_watch (worker->srv->cfg, ctx->event_loop, ctx->resolver,
-                               worker, 0);
+                               worker, RSPAMD_MAP_WATCH_SCANNER);
        }
 
        rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->event_loop,