struct rspamd_rcl_default_handler_data {
struct rspamd_rcl_struct_parser pd;
- const gchar *key;
+ gchar *key;
rspamd_rcl_default_handler_t handler;
UT_hash_handle hh;
};
if (rspamd_rcl_section_parse_defaults (cfg, section, pool, obj, st, err)) {
ccf->statfiles = g_list_prepend (ccf->statfiles, st);
+
if (st->label != NULL) {
labels = g_hash_table_lookup (ccf->labels, st->label);
if (labels != NULL) {
gint flags,
const gchar *doc_string)
{
- struct rspamd_rcl_default_handler_data *new;
+ struct rspamd_rcl_default_handler_data *nhandler;
- new = g_slice_alloc0 (sizeof (struct rspamd_rcl_default_handler_data));
- new->key = name;
- new->handler = handler;
- new->pd.offset = offset;
- new->pd.flags = flags;
+ nhandler = g_slice_alloc0 (sizeof (struct rspamd_rcl_default_handler_data));
+ nhandler->key = g_strdup (name);
+ nhandler->handler = handler;
+ nhandler->pd.offset = offset;
+ nhandler->pd.flags = flags;
if (section->doc_ref != NULL) {
rspamd_rcl_add_doc_obj (section->doc_ref,
0);
}
- HASH_ADD_KEYPTR (hh, section->default_parser, new->key, strlen (
- new->key), new);
- return new;
+ HASH_ADD_KEYPTR (hh, section->default_parser, nhandler->key, strlen (
+ nhandler->key), nhandler);
+ return nhandler;
}
struct rspamd_rcl_section *
return FALSE;
}
+ rspamd_mempool_add_destructor (pool,
+ (rspamd_mempool_destruct_t)rspamd_pubkey_unref, pk);
+
return TRUE;
}
rspamd_rcl_section_free (gpointer p)
{
struct rspamd_rcl_section *top = p, *cur, *tmp;
+ struct rspamd_rcl_default_handler_data *dh, *dhtmp;
HASH_ITER (hh, top, cur, tmp) {
HASH_DEL (top, cur);
rspamd_rcl_section_free (cur->subsections);
}
+ HASH_ITER (hh, cur->default_parser, dh, dhtmp) {
+ HASH_DEL (cur->default_parser, dh);
+ g_free (dh->key);
+ g_slice_free1 (sizeof (*dh), dh);
+ }
+
ucl_object_unref (cur->doc_ref);
g_slice_free1 (sizeof (*cur), cur);
}
cfg->max_diff = 20480;
cfg->metrics = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
- if (cfg->c_modules == NULL) {
- cfg->c_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
- }
+ cfg->c_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->composite_symbols =
g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->classifiers_symbols = g_hash_table_new (rspamd_str_hash,
g_list_free (cfg->classifiers);
g_list_free (cfg->metrics_list);
+ g_list_free (cfg->workers);
rspamd_symbols_cache_destroy (cfg->cache);
#ifdef WITH_HIREDIS
if (cfg->redis_pool) {
}
}
+ if (bk->trusted_pubkey) {
+ rspamd_pubkey_unref (bk->trusted_pubkey);
+ }
+
g_slice_free1 (sizeof (*bk), bk);
}
return NULL;
}
- map = g_slice_alloc0 (sizeof (struct rspamd_map));
+ map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_map));
map->read_callback = read_callback;
map->fin_callback = fin_callback;
map->user_data = user_data;
map->cache =
rspamd_mempool_alloc0_shared (cfg->cfg_pool, sizeof (*map->cache));
map->backends = g_ptr_array_sized_new (1);
+ rspamd_mempool_add_destructor (cfg->cfg_pool, rspamd_ptr_array_free_hard,
+ map->backends);
g_ptr_array_add (map->backends, bk);
- map->name = g_strdup (map_line);
+ map->name = rspamd_mempool_strdup (cfg->cfg_pool, map_line);
map->poll_timeout = cfg->map_timeout;
if (description != NULL) {
- map->description = g_strdup (description);
+ map->description = rspamd_mempool_strdup (cfg->cfg_pool, description);
}
rspamd_map_calculate_hash (map);
read_callback, fin_callback, user_data);
}
- map = g_slice_alloc0 (sizeof (struct rspamd_map));
+ map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_map));
map->read_callback = read_callback;
map->fin_callback = fin_callback;
map->user_data = user_data;
map->cache =
rspamd_mempool_alloc0_shared (cfg->cfg_pool, sizeof (*map->cache));
map->backends = g_ptr_array_new ();
+ rspamd_mempool_add_destructor (cfg->cfg_pool, rspamd_ptr_array_free_hard,
+ map->backends);
map->poll_timeout = cfg->map_timeout;
if (description) {
- map->description = g_strdup (description);
+ map->description = rspamd_mempool_strdup (cfg->cfg_pool, description);
}
if (ucl_object_type (obj) == UCL_ARRAY) {
return map;
err:
- g_ptr_array_free (map->backends, TRUE);
- g_free (map->name);
- g_free (map->description);
- g_slice_free1 (sizeof (*map), map);
return NULL;
}
while (p < end) {
len = strcspn (p, separators);
+
if (len > 0) {
tmp = g_malloc (len + 1);
rspamd_strlcpy (tmp, p, len + 1);
+
if (rspamd_upstreams_add_upstream (ups, tmp, def_port, data)) {
ret = TRUE;
}
- else {
- g_free (tmp);
- }
+
+ g_free (tmp);
}
+
p += len;
/* Skip separators */
p += strspn (p, separators);
}
else if (strcmp (type, "set") == 0) {
map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*map));
- map->data.hash = g_hash_table_new (rspamd_strcase_hash,
- rspamd_strcase_equal);
+ map->data.hash = NULL;
map->type = RSPAMD_LUA_MAP_SET;
if ((m = rspamd_map_add_from_ucl (cfg, map_obj, description,
rspamd_hosts_read,
rspamd_hosts_fin,
(void **)&map->data.hash)) == NULL) {
- g_hash_table_destroy (map->data.hash);
lua_pushnil (L);
ucl_object_unref (map_obj);
}
else if (strcmp (type, "map") == 0 || strcmp (type, "hash") == 0) {
map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*map));
- map->data.hash = g_hash_table_new (rspamd_strcase_hash,
- rspamd_strcase_equal);
+ map->data.hash = NULL;
map->type = RSPAMD_LUA_MAP_HASH;
if ((m = rspamd_map_add_from_ucl (cfg, map_obj, description,
rspamd_kv_list_read,
rspamd_kv_list_fin,
(void **)&map->data.hash)) == NULL) {
- g_hash_table_destroy (map->data.hash);
lua_pushnil (L);
ucl_object_unref (map_obj);
}
else if (strcmp (type, "radix") == 0) {
map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*map));
- map->data.radix = radix_create_compressed ();
+ map->data.radix = NULL;
map->type = RSPAMD_LUA_MAP_RADIX;
if ((m = rspamd_map_add_from_ucl (cfg, map_obj, description,
rspamd_radix_read,
rspamd_radix_fin,
(void **)&map->data.radix)) == NULL) {
- radix_destroy_compressed (map->data.radix);
lua_pushnil (L);
ucl_object_unref (map_obj);
luaL_register (L, NULL, regexplib_m);
rspamd_lua_add_preload (L, "rspamd_regexp", lua_load_regexp);
- regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
+ if (regexp_static_pool == NULL) {
+ regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
+ "regexp_lua_pool");
+ }
+
lua_settop (L, 0);
}
strvec = g_strsplit_set (str, ",", 0);
num = g_strv_length (strvec);
res = g_ptr_array_sized_new (num);
+ rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
+ rspamd_ptr_array_free_hard, res);
for (i = 0; i < num; i++) {
g_strstrip (strvec[i]);
type->type_re = rspamd_regexp_from_glob (strvec[i], p - strvec[i],
NULL);
type->subtype_re = rspamd_regexp_from_glob (p + 1, 0, NULL);
+ rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
+ (rspamd_mempool_destruct_t)rspamd_regexp_unref,
+ type->type_re);
+ rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
+ (rspamd_mempool_destruct_t)rspamd_regexp_unref,
+ type->subtype_re);
g_ptr_array_add (res, type);
}
else {
type = rspamd_mempool_alloc (fuzzy_module_ctx->fuzzy_pool,
sizeof (struct fuzzy_mime_type));
type->type_re = rspamd_regexp_from_glob (strvec[i], 0, NULL);
+ rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
+ (rspamd_mempool_destruct_t)rspamd_regexp_unref,
+ type->type_re);
type->subtype_re = NULL;
g_ptr_array_add (res, type);
}
gchar *cfg_file;
tmp_cfg = rspamd_config_new ();
+ g_hash_table_unref (tmp_cfg->c_modules);
tmp_cfg->c_modules = g_hash_table_ref (rspamd_main->cfg->c_modules);
tmp_cfg->libs_ctx = rspamd_main->cfg->libs_ctx;
REF_RETAIN (tmp_cfg->libs_ctx);
}
}
}
+
+ g_ptr_array_free (seen_mandatory_workers);
}
static void
close (cur->control_pipe[0]);
close (cur->srv_pipe[0]);
REF_RELEASE (cur->cf);
+ g_ptr_array_free (cur->finish_actions, TRUE);
g_free (cur);
}
else {