rspamd_worker_init_monitored (worker, ctx->ev_base, ctx->resolver);
}
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, TRUE);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base,
+ ctx->resolver, worker, TRUE);
}
else {
- rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, FALSE);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base,
+ ctx->resolver, worker, FALSE);
}
rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base, worker);
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, 0);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, worker, 0);
/* Get peer pipe */
memset (&srv_cmd, 0, sizeof (srv_cmd));
g_hash_table_unref (worker->signal_events);
#endif
-
- /* Cleanup maps */
- rspamd_map_remove_all (worker->srv->cfg);
}
static rspamd_fstring_t *
gdouble timeout;
struct map_periodic_cbdata *cbd;
- if (map->scheduled_check) {
+ if (map->scheduled_check || (map->wrk && map->wrk->wanna_die)) {
/* Do not schedule check if some check is already scheduled */
return;
}
return;
}
- bk = g_ptr_array_index (cbd->map->backends, cbd->cur_backend);
- g_assert (bk != NULL);
-
- if (cbd->need_modify) {
- /* Load data from the next backend */
- switch (bk->protocol) {
- case MAP_PROTO_HTTP:
- case MAP_PROTO_HTTPS:
- rspamd_map_http_read_callback (fd, what, cbd);
- break;
- case MAP_PROTO_FILE:
- rspamd_map_file_read_callback (fd, what, cbd);
- break;
- case MAP_PROTO_STATIC:
- rspamd_map_static_read_callback (fd, what, cbd);
- break;
- }
- }
- else {
- /* Check the next backend */
- switch (bk->protocol) {
- case MAP_PROTO_HTTP:
- case MAP_PROTO_HTTPS:
- rspamd_map_http_check_callback (fd, what, cbd);
- break;
- case MAP_PROTO_FILE:
- rspamd_map_file_check_callback (fd, what, cbd);
- break;
- case MAP_PROTO_STATIC:
- rspamd_map_static_check_callback (fd, what, cbd);
- break;
+ if (!(cbd->map->wrk && cbd->map->wrk->wanna_die)) {
+ bk = g_ptr_array_index (cbd->map->backends, cbd->cur_backend);
+ g_assert (bk != NULL);
+
+ if (cbd->need_modify) {
+ /* Load data from the next backend */
+ switch (bk->protocol) {
+ case MAP_PROTO_HTTP:
+ case MAP_PROTO_HTTPS:
+ rspamd_map_http_read_callback (fd, what, cbd);
+ break;
+ case MAP_PROTO_FILE:
+ rspamd_map_file_read_callback (fd, what, cbd);
+ break;
+ case MAP_PROTO_STATIC:
+ rspamd_map_static_read_callback (fd, what, cbd);
+ break;
+ }
+ } else {
+ /* Check the next backend */
+ switch (bk->protocol) {
+ case MAP_PROTO_HTTP:
+ case MAP_PROTO_HTTPS:
+ rspamd_map_http_check_callback (fd, what, cbd);
+ break;
+ case MAP_PROTO_FILE:
+ rspamd_map_file_check_callback (fd, what, cbd);
+ break;
+ case MAP_PROTO_STATIC:
+ rspamd_map_static_check_callback (fd, what, cbd);
+ break;
+ }
}
}
}
/* Start watching event for all maps */
void
-rspamd_map_watch (struct rspamd_config *cfg, struct event_base *ev_base,
- struct rspamd_dns_resolver *resolver, gboolean active_http)
+rspamd_map_watch (struct rspamd_config *cfg,
+ struct event_base *ev_base,
+ struct rspamd_dns_resolver *resolver,
+ struct rspamd_worker *worker,
+ gboolean active_http)
{
GList *cur = cfg->maps;
struct rspamd_map *map;
map = cur->data;
map->ev_base = ev_base;
map->r = resolver;
+ map->wrk = worker;
if (active_http) {
map->active_http = active_http;
if (access (bk->uri, R_OK) == -1) {
if (errno != ENOENT) {
msg_err_config ("cannot open file '%s': %s", bk->uri, strerror (errno));
- return NULL;
-
+ goto err;
}
+
msg_info_config (
"map '%s' is not found, but it can be loaded automatically later",
bk->uri);
else {
if (!(up.field_set & 1 << UF_HOST)) {
msg_err_config ("cannot parse HTTP url: %s: no host", bk->uri);
- return NULL;
+ goto err;
}
tok.begin = bk->uri + up.field_data[UF_HOST].off;
}
bk->data.hd = hdata;
- }else if (bk->protocol == MAP_PROTO_STATIC) {
+ }
+ else if (bk->protocol == MAP_PROTO_STATIC) {
sdata = g_malloc0 (sizeof (*sdata));
bk->data.sd = sdata;
}
/**
* 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, gboolean active_http);
+void rspamd_map_watch (struct rspamd_config *cfg,
+ struct event_base *ev_base,
+ struct rspamd_dns_resolver *resolver,
+ struct rspamd_worker *worker,
+ gboolean active_http);
/**
* Remove all maps watched (remove events)
map_dtor_t dtor;
void **user_data;
struct event_base *ev_base;
+ struct rspamd_worker *wrk;
gchar *description;
gchar *name;
guint32 id;
if (data->cur_data == NULL) {
t = data->prev_data;
- for (i = 0; i < MAX_LEVELS; i++) {
- if (t[i] != NULL) {
- g_hash_table_destroy (t[i]);
+ if (t) {
+ for (i = 0; i < MAX_LEVELS; i++) {
+ if (t[i] != NULL) {
+ g_hash_table_destroy (t[i]);
+ }
+ t[i] = NULL;
}
- t[i] = NULL;
+
+ g_free (t);
}
- data->cur_data = data->prev_data;
+ data->cur_data = g_malloc0 (MAX_LEVELS * sizeof (GHashTable *));
}
return rspamd_parse_kv_list (
}
t[i] = NULL;
}
+
+ g_free (t);
}
}
surbl_module_ctx->use_redirector = 0;
surbl_module_ctx->suffixes = NULL;
- surbl_module_ctx->surbl_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
+ surbl_module_ctx->surbl_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
+ NULL);
surbl_module_ctx->redirectors = NULL;
surbl_module_ctx->whitelist = NULL;
- rspamd_mempool_add_destructor (surbl_module_ctx->surbl_pool,
- (rspamd_mempool_destruct_t) rspamd_map_helper_destroy_hash,
- surbl_module_ctx->whitelist);
- surbl_module_ctx->exceptions = rspamd_mempool_alloc0 (
- surbl_module_ctx->surbl_pool, MAX_LEVELS * sizeof (GHashTable *));
+ surbl_module_ctx->exceptions = NULL;
surbl_module_ctx->redirector_cbid = -1;
surbl_module_ctx->redirectors = NULL;
surbl_module_ctx->whitelist = NULL;
/* Zero exceptions hashes */
- surbl_module_ctx->exceptions = rspamd_mempool_alloc0 (
- surbl_module_ctx->surbl_pool,
- MAX_LEVELS * sizeof (GHashTable *));
- /* Register destructors */
- rspamd_mempool_add_destructor (surbl_module_ctx->surbl_pool,
- (rspamd_mempool_destruct_t) rspamd_map_helper_destroy_hash,
- surbl_module_ctx->whitelist);
- rspamd_mempool_add_destructor (surbl_module_ctx->surbl_pool,
- (rspamd_mempool_destruct_t) g_hash_table_destroy,
- surbl_module_ctx->redirector_tlds);
+ surbl_module_ctx->exceptions = NULL;
rspamd_mempool_add_destructor (surbl_module_ctx->surbl_pool,
(rspamd_mempool_destruct_t) g_list_free,
/* Not a numeric url */
result = rspamd_mempool_alloc (pool, len);
/* Now we should try to check for exceptions */
- if (!forced) {
+ if (!forced && surbl_module_ctx->exceptions) {
for (i = MAX_LEVELS - 1; i >= 0; i--) {
t = surbl_module_ctx->exceptions[i];
if (t != NULL && dots_num >= i + 1) {
RVERSION
" is restarting");
g_hash_table_foreach (rspamd_main->workers, kill_old_workers, NULL);
- rspamd_map_remove_all (rspamd_main->cfg);
rspamd_log_close_priv (rspamd_main->logger,
rspamd_main->workers_uid,
rspamd_main->workers_gid);
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, 0);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, worker, 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, 0);
+ rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, worker, 0);
rspamd_upstreams_library_config (worker->srv->cfg, ctx->cfg->ups_ctx,
ctx->ev_base, ctx->resolver->r);