]> granicus.if.org Git - libevent/commitdiff
evdns: fail ns after we are failing/retrasmitting request
authorAzat Khuzhin <a3at.mail@gmail.com>
Mon, 29 Sep 2014 21:34:04 +0000 (01:34 +0400)
committerAzat Khuzhin <a3at.mail@gmail.com>
Mon, 29 Sep 2014 21:40:44 +0000 (01:40 +0400)
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

diff --git a/evdns.c b/evdns.c
index 5ec6a06008ee5f01a7f13fc185862817bc04d50f..fdffbd70a2b125d85fff3250b37f27d7bf4429bc 100644 (file)
--- 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);
 }