aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-07-26 01:37:38 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-07-26 01:37:38 +0400
commit412d2de17d436399b4b4a5580ea1801a19a30a7e (patch)
tree0ef9a24f139f9280383f08e671c7d00e05f6e69f
parentbe8c6f0ce040a5f9d17d17b356a97712d912f7b1 (diff)
downloadrspamd-412d2de17d436399b4b4a5580ea1801a19a30a7e.tar.gz
rspamd-412d2de17d436399b4b4a5580ea1801a19a30a7e.zip
Fix up another event related problem.
-rw-r--r--src/dns.c8
-rw-r--r--src/plugins/fuzzy_check.c2
2 files changed, 4 insertions, 6 deletions
diff --git a/src/dns.c b/src/dns.c
index 5148e742b..2f5e99e38 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -539,7 +539,6 @@ send_dns_request (struct rspamd_dns_request *req)
r = send (req->sock, req->packet, req->pos, 0);
if (r == -1) {
if (errno == EAGAIN) {
- event_del (&req->io_event);
event_set (&req->io_event, req->sock, EV_WRITE, dns_retransmit_handler, req);
event_add (&req->io_event, &req->tv);
register_async_event (req->session, (event_finalizer_t)event_del, &req->io_event, FALSE);
@@ -552,7 +551,6 @@ send_dns_request (struct rspamd_dns_request *req)
}
}
else if (r < req->pos) {
- event_del (&req->io_event);
event_set (&req->io_event, req->sock, EV_WRITE, dns_retransmit_handler, req);
event_add (&req->io_event, &req->tv);
register_async_event (req->session, (event_finalizer_t)event_del, &req->io_event, FALSE);
@@ -1086,7 +1084,6 @@ dns_timer_cb (gint fd, short what, void *arg)
evtimer_add (&req->timer_event, &req->tv);
r = send_dns_request (req);
if (r == -1) {
- event_del (&req->io_event);
rep = memory_pool_alloc0 (req->pool, sizeof (struct rspamd_dns_reply));
rep->request = req;
rep->code = DNS_RC_SERVFAIL;
@@ -1107,9 +1104,9 @@ dns_retransmit_handler (gint fd, short what, void *arg)
if (what == EV_WRITE) {
/* Retransmit dns request */
req->retransmits ++;
+ event_del (&req->io_event);
if (req->retransmits >= req->resolver->max_retransmits) {
msg_err ("maximum number of retransmits expired for %s", req->requested_name);
- event_del (&req->io_event);
rep = memory_pool_alloc0 (req->pool, sizeof (struct rspamd_dns_reply));
rep->request = req;
rep->code = DNS_RC_SERVFAIL;
@@ -1123,7 +1120,6 @@ dns_retransmit_handler (gint fd, short what, void *arg)
}
r = send_dns_request (req);
if (r == -1) {
- event_del (&req->io_event);
rep = memory_pool_alloc0 (req->pool, sizeof (struct rspamd_dns_reply));
rep->request = req;
rep->code = DNS_RC_SERVFAIL;
@@ -1227,13 +1223,13 @@ make_dns_request (struct rspamd_dns_resolver *resolver,
/* Fill timeout */
msec_to_tv (resolver->request_timeout, &req->tv);
+ evtimer_set (&req->timer_event, dns_timer_cb, req);
/* Now send request to server */
r = send_dns_request (req);
if (r == 1) {
/* Add timer event */
- evtimer_set (&req->timer_event, dns_timer_cb, req);
evtimer_add (&req->timer_event, &req->tv);
/* Add request to hash table */
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index eafbbeb90..30e58fa45 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -474,6 +474,7 @@ fuzzy_io_callback (gint fd, short what, void *arg)
goto err;
}
else {
+ event_del (&session->ev);
event_set (&session->ev, fd, EV_READ, fuzzy_io_callback, session);
event_add (&session->ev, &session->tv);
}
@@ -559,6 +560,7 @@ fuzzy_learn_callback (gint fd, short what, void *arg)
goto err;
}
else {
+ event_del (&session->ev);
event_set (&session->ev, fd, EV_READ, fuzzy_learn_callback, session);
event_add (&session->ev, &session->tv);
}