gint len,
struct map_cb_data *data,
gboolean final);
-static void rspamd_ucl_fin_cb (struct map_cb_data *data);
+static void rspamd_ucl_fin_cb (struct map_cb_data *data, void **target);
static void rspamd_ucl_dtor_cb (struct map_cb_data *data);
guint rspamd_config_log_id = (guint)-1;
}
static void
-rspamd_ucl_fin_cb (struct map_cb_data *data)
+rspamd_ucl_fin_cb (struct map_cb_data *data, void **target)
{
struct rspamd_ucl_map_cbdata *cbdata = data->cur_data, *prev =
data->prev_data;
const ucl_object_t *cur;
struct rspamd_config *cfg = data->map->cfg;
- if (prev != NULL) {
- if (prev->buf != NULL) {
- g_string_free (prev->buf, TRUE);
- }
- g_free (prev);
- }
-
if (cbdata == NULL) {
msg_err_config ("map fin error: new data is NULL");
return;
}
ucl_object_unref (obj);
}
+
+ if (target) {
+ *target = data->cur_data;
+ }
+
+ if (prev != NULL) {
+ if (prev->buf != NULL) {
+ g_string_free (prev->buf, TRUE);
+ }
+ g_free (prev);
+ }
}
static void
}
static void
-json_config_fin_cb (struct map_cb_data *data)
+json_config_fin_cb (struct map_cb_data *data, void **target)
{
struct config_json_buf *jb;
ucl_object_t *top;
struct ucl_parser *parser;
- if (data->cur_data && data->prev_data) {
- jb = data->prev_data;
- /* Clean prev data */
- if (jb->buf) {
- g_string_free (jb->buf, TRUE);
- }
-
- g_free (jb);
- }
-
/* Now parse json */
if (data->cur_data) {
jb = data->cur_data;
if (jb->buf == NULL) {
msg_err ("no data read");
+
return;
}
ucl_object_unref (jb->cfg->current_dynamic_conf);
apply_dynamic_conf (top, jb->cfg);
jb->cfg->current_dynamic_conf = top;
+
+ if (target) {
+ *target = data->cur_data;
+ }
+
+ if (data->prev_data) {
+ jb = data->prev_data;
+ /* Clean prev data */
+ if (jb->buf) {
+ g_string_free (jb->buf, TRUE);
+ }
+
+ g_free (jb);
+ }
}
static void
if (periodic->need_modify) {
/* We are done */
- periodic->map->fin_callback (&periodic->cbdata);
-
- if (periodic->cbdata.cur_data) {
- *periodic->map->user_data = periodic->cbdata.cur_data;
- }
+ periodic->map->fin_callback (&periodic->cbdata, periodic->map->user_data);
}
else {
/* Not modified */
}
if (succeed) {
- map->fin_callback (&fake_cbd.cbdata);
-
- if (fake_cbd.cbdata.cur_data) {
- *map->user_data = fake_cbd.cbdata.cur_data;
- }
+ map->fin_callback (&fake_cbd.cbdata, map->user_data);
}
else {
msg_info_map ("preload of %s failed", map->name);
*/
typedef gchar * (*map_cb_t)(gchar *chunk, gint len,
struct map_cb_data *data, gboolean final);
-typedef void (*map_fin_cb_t)(struct map_cb_data *data);
+typedef void (*map_fin_cb_t)(struct map_cb_data *data, void **target);
typedef void (*map_dtor_t)(struct map_cb_data *data);
typedef gboolean (*rspamd_map_traverse_cb)(gconstpointer key,
}
void
-rspamd_kv_list_fin (struct map_cb_data *data)
+rspamd_kv_list_fin (struct map_cb_data *data, void **target)
{
struct rspamd_map *map = data->map;
struct rspamd_hash_map_helper *htb;
- if (data->prev_data) {
- htb = (struct rspamd_hash_map_helper *)data->prev_data;
- rspamd_map_helper_destroy_hash (htb);
- }
-
if (data->cur_data) {
htb = (struct rspamd_hash_map_helper *)data->cur_data;
msg_info_map ("read hash of %d elements", kh_size (htb->htb));
data->map->nelts = kh_size (htb->htb);
data->map->digest = rspamd_cryptobox_fast_hash_final (&htb->hst);
}
+
+ if (target) {
+ *target = data->cur_data;
+ }
+
+ if (data->prev_data) {
+ htb = (struct rspamd_hash_map_helper *)data->prev_data;
+ rspamd_map_helper_destroy_hash (htb);
+ }
}
void
}
void
-rspamd_radix_fin (struct map_cb_data *data)
+rspamd_radix_fin (struct map_cb_data *data, void **target)
{
struct rspamd_map *map = data->map;
struct rspamd_radix_map_helper *r;
- if (data->prev_data) {
- r = (struct rspamd_radix_map_helper *)data->prev_data;
- rspamd_map_helper_destroy_radix (r);
- }
-
if (data->cur_data) {
r = (struct rspamd_radix_map_helper *)data->cur_data;
msg_info_map ("read radix trie of %z elements: %s",
data->map->nelts = kh_size (r->htb);
data->map->digest = rspamd_cryptobox_fast_hash_final (&r->hst);
}
+
+ if (target) {
+ *target = data->cur_data;
+ }
+
+ if (data->prev_data) {
+ r = (struct rspamd_radix_map_helper *)data->prev_data;
+ rspamd_map_helper_destroy_radix (r);
+ }
}
void
void
-rspamd_regexp_list_fin (struct map_cb_data *data)
+rspamd_regexp_list_fin (struct map_cb_data *data, void **target)
{
struct rspamd_regexp_map_helper *re_map;
struct rspamd_map *map = data->map;
- if (data->prev_data) {
- rspamd_map_helper_destroy_regexp (data->prev_data);
- }
if (data->cur_data) {
re_map = data->cur_data;
rspamd_re_map_finalize (re_map);
data->map->nelts = kh_size (re_map->htb);
data->map->digest = rspamd_cryptobox_fast_hash_final (&re_map->hst);
}
+
+ if (target) {
+ *target = data->cur_data;
+ }
+
+ if (data->prev_data) {
+ rspamd_map_helper_destroy_regexp (data->prev_data);
+ }
}
void
rspamd_regexp_list_dtor (struct map_cb_data *data)
gint len,
struct map_cb_data *data,
gboolean final);
-void rspamd_radix_fin (struct map_cb_data *data);
+void rspamd_radix_fin (struct map_cb_data *data, void **target);
void rspamd_radix_dtor (struct map_cb_data *data);
/**
gint len,
struct map_cb_data *data,
gboolean final);
-void rspamd_kv_list_fin (struct map_cb_data *data);
+void rspamd_kv_list_fin (struct map_cb_data *data, void **target);
void rspamd_kv_list_dtor (struct map_cb_data *data);
/**
gint len,
struct map_cb_data *data,
gboolean final);
-void rspamd_regexp_list_fin (struct map_cb_data *data);
+void rspamd_regexp_list_fin (struct map_cb_data *data, void **target);
void rspamd_regexp_list_dtor (struct map_cb_data *data);
/**
}
static void
-lua_map_fin (struct map_cb_data *data)
+lua_map_fin (struct map_cb_data *data, void **target)
{
struct lua_map_callback_data *cbdata;
struct rspamd_lua_map **pmap;
return;
}
- if (data->prev_data) {
- data->prev_data = NULL;
- }
-
if (cbdata->ref == -1) {
msg_err_map ("map has no callback set");
}
}
cbdata->data = rspamd_fstring_assign (cbdata->data, "", 0);
+
+ if (target) {
+ *target = data->cur_data;
+ }
+
+ if (data->prev_data) {
+ data->prev_data = NULL;
+ }
}
static void
}
static void
-fin_exceptions_list (struct map_cb_data *data)
+fin_exceptions_list (struct map_cb_data *data, void **target)
{
GHashTable **t;
gint i;
+ if (target) {
+ *target = data->cur_data;
+ }
+
if (data->prev_data) {
t = data->prev_data;
for (i = 0; i < MAX_LEVELS; i++) {
final);
}
-void
-fin_redirectors_list (struct map_cb_data *data)
+static void
+fin_redirectors_list (struct map_cb_data *data, void **target)
{
GHashTable *tld_hash;
+ if (target) {
+ *target = data->cur_data;
+ }
+
if (data->prev_data) {
tld_hash = data->prev_data;
}
}
-void
+static void
dtor_redirectors_list (struct map_cb_data *data)
{
GHashTable *tld_hash;