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); }