#include "utlist.h"
#include "ottery.h"
#include "rspamd_control.h"
+#include "libutil/map.h"
+#include "libutil/map_private.h"
#ifdef WITH_GPERF_TOOLS
#include <gperftools/profiler.h>
GHashTableIter it;
struct rspamd_worker_signal_handler *sigh;
gpointer k, v;
+ struct rspamd_map *map;
/* Remove all events */
cur = worker->accept_events;
}
g_hash_table_iter_init (&it, worker->signal_events);
+
while (g_hash_table_iter_next (&it, &k, &v)) {
sigh = (struct rspamd_worker_signal_handler *)v;
g_hash_table_iter_steal (&it);
}
g_free (sigh);
}
+
g_hash_table_unref (worker->signal_events);
+
+ /* Cleanup maps */
+ for (cur = worker->srv->cfg->maps; cur != NULL; cur = g_list_next (cur)) {
+ map = cur->data;
+
+ if (map->dtor) {
+ map->dtor (map->dtor_data);
+ }
+ }
}
void
#include "http_parser.h"
static const gchar *hash_fill = "1";
+static void free_http_cbdata_common (struct http_callback_data *cbd);
+static void free_http_cbdata_dtor (gpointer p);
static void free_http_cbdata (struct http_callback_data *cbd);
/**
* Write HTTP request
* Callback for destroying HTTP callback data
*/
static void
-free_http_cbdata (struct http_callback_data *cbd)
+free_http_cbdata_common (struct http_callback_data *cbd)
{
char fpath[PATH_MAX];
struct stat st;
g_slice_free1 (sizeof (struct http_callback_data), cbd);
}
+static void
+free_http_cbdata (struct http_callback_data *cbd)
+{
+ cbd->map->dtor = NULL;
+ cbd->map->dtor_data = NULL;
+
+ free_http_cbdata_common (cbd);
+}
+
+static void
+free_http_cbdata_dtor (gpointer p)
+{
+ struct http_callback_data *cbd = p;
+ rspamd_mempool_t *pool;
+
+ pool = cbd->map->pool;
+ msg_warn_pool ("connection with http server is terminated: worker is stopping");
+ free_http_cbdata_common (cbd);
+}
+
/*
* HTTP callbacks
*/
data->host, RDNS_REQUEST_AAAA)) {
REF_RETAIN (cbd);
}
+
jitter_timeout_event (map, FALSE, FALSE, FALSE);
+ map->dtor = free_http_cbdata_dtor;
+ map->dtor_data = cbd;
}
else {
msg_warn_pool ("cannot load map: DNS resolver is not initialized");
void
rspamd_map_remove_all (struct rspamd_config *cfg)
{
+ struct rspamd_map *map;
+ GList *cur;
+
+ for (cur = cfg->maps; cur != NULL; cur = g_list_next (cur)) {
+ map = cur->data;
+
+ if (map->dtor) {
+ map->dtor (map->dtor_data);
+ }
+ }
+
g_list_free (cfg->maps);
cfg->maps = NULL;
+
if (cfg->map_pool != NULL) {
rspamd_mempool_delete (cfg->map_pool);
cfg->map_pool = NULL;