From 412d2de17d436399b4b4a5580ea1801a19a30a7e Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 26 Jul 2011 01:37:38 +0400 Subject: [PATCH] Fix up another event related problem. --- src/dns.c | 8 ++------ src/plugins/fuzzy_check.c | 2 ++ 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); } -- 2.39.5