From 97c750d6602517f22a1100f16592b421c38f2a45 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 30 Sep 2014 01:34:04 +0400 Subject: [PATCH] evdns: fail ns after we are failing/retrasmitting request In case we are failing request (evdns_request_timeout_callback()), we delete timeout_event in request_finished(), while just before calling request_finished() (for failing request) there was a call to nameserver_failed(), that add event for timeout_event, IOW we must fail ns after request because otherwise we will not have timeout_event actived, and we will waiting forever. Before this patch the dns/retry_disable_when_inactive will wait forever, after - OK. --- evdns.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/evdns.c b/evdns.c index 5ec6a060..fdffbd70 100644 --- a/evdns.c +++ b/evdns.c @@ -2170,12 +2170,6 @@ evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg) { log(EVDNS_LOG_DEBUG, "Request %p timed out", arg); EVDNS_LOCK(base); - req->ns->timedout++; - if (req->ns->timedout > req->base->global_max_nameserver_timeout) { - req->ns->timedout = 0; - nameserver_failed(req->ns, "request timed out."); - } - if (req->tx_count >= req->base->global_max_retransmits) { /* this request has failed */ log(EVDNS_LOG_DEBUG, "Giving up on request %p; tx_count==%d", @@ -2190,6 +2184,13 @@ evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg) { request_swap_ns(req, nameserver_pick(base)); evdns_request_transmit(req); } + + req->ns->timedout++; + if (req->ns->timedout > req->base->global_max_nameserver_timeout) { + req->ns->timedout = 0; + nameserver_failed(req->ns, "request timed out."); + } + EVDNS_UNLOCK(base); } -- 2.40.0