summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-05-01 15:20:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-05-01 15:20:06 +0100
commit112e46f516bdebea70e970c67aa660480157a683 (patch)
treebd6c6a256b1c4a99892730e6be8274aa17018195 /src
parentb8566c7685333af8277d1cb919ae0e5f1d2ed3cf (diff)
downloadrspamd-112e46f516bdebea70e970c67aa660480157a683.tar.gz
rspamd-112e46f516bdebea70e970c67aa660480157a683.zip
Fix race condition in DNS events.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/dns.c7
-rw-r--r--src/libserver/events.c3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c
index 8d18ffc06..c1303e3ea 100644
--- a/src/libserver/dns.c
+++ b/src/libserver/dns.c
@@ -59,6 +59,11 @@ rspamd_dns_callback (struct rdns_reply *reply, gpointer ud)
reqdata->cb (reply, reqdata->ud);
+ /*
+ * Ref event to avoid double unref by
+ * event removing
+ */
+ rdns_request_retain (reply->request);
remove_normal_event (reqdata->session, rspamd_dns_fin_cb, reqdata->req);
}
@@ -81,8 +86,6 @@ make_dns_request (struct rspamd_dns_resolver *resolver,
if (req != NULL) {
register_async_event (session, (event_finalizer_t)rspamd_dns_fin_cb, req,
g_quark_from_static_string ("dns resolver"));
- /* Ref event to free it only when according async event is deleted from the session */
- rdns_request_retain (req);
reqdata->req = req;
}
else {
diff --git a/src/libserver/events.c b/src/libserver/events.c
index 85843fd05..48dcb3444 100644
--- a/src/libserver/events.c
+++ b/src/libserver/events.c
@@ -154,6 +154,9 @@ rspamd_session_destroy (gpointer k, gpointer v, gpointer unused)
struct rspamd_async_event *ev = v;
/* Call event's finalizer */
+ msg_debug ("removed event on destroy: %p, subsystem: %s", ev->user_data,
+ g_quark_to_string (ev->subsystem));
+
if (ev->fin != NULL) {
ev->fin (ev->user_data);
}