]> granicus.if.org Git - libevent/commitdiff
test/dns: run async resolving after sync one (to avoid timeouts)
authorAzat Khuzhin <a3at.mail@gmail.com>
Thu, 19 Jan 2017 17:34:41 +0000 (20:34 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Thu, 19 Jan 2017 17:50:22 +0000 (20:50 +0300)
If system resolver (sync one) will respond too slow, then we can fail async
request and evdns will retransmit tham again, but evdns server will accept that
failed requets, so we will have not 2 requests but 4.

Reproduced on centos box sometimes.

test/regress_dns.c

index 11c015c502b0b78d16a08b21ae21501574c5dc98..feef02222e79ae29ee2b2c17046a15a65aa322d4 100644 (file)
@@ -1250,15 +1250,6 @@ test_bufferevent_connect_hostname(void *arg)
        bufferevent_setcb(be5, NULL, NULL, be_connect_hostname_event_cb,
            &be5_outcome);
 
-       /* Launch an async resolve that will fail. */
-       tt_assert(!bufferevent_socket_connect_hostname(be1, dns, AF_INET,
-               "nosuchplace.example.com", listener_port));
-       /* Connect to the IP without resolving. */
-       tt_assert(!bufferevent_socket_connect_hostname(be2, dns, AF_INET,
-               "127.0.0.1", listener_port));
-       /* Launch an async resolve that will succeed. */
-       tt_assert(!bufferevent_socket_connect_hostname(be3, dns, AF_INET,
-               "nobodaddy.example.com", listener_port));
        /* Use the blocking resolver.  This one will fail if your resolver
         * can't resolve localhost to 127.0.0.1 */
        tt_assert(!bufferevent_socket_connect_hostname(be4, NULL, AF_INET,
@@ -1278,6 +1269,15 @@ test_bufferevent_connect_hostname(void *arg)
                expect_err5 = evutil_getaddrinfo(
                        "nonesuch.nowhere.example.com", "80", &hints, &ai);
        }
+       /* Launch an async resolve that will fail. */
+       tt_assert(!bufferevent_socket_connect_hostname(be1, dns, AF_INET,
+               "nosuchplace.example.com", listener_port));
+       /* Connect to the IP without resolving. */
+       tt_assert(!bufferevent_socket_connect_hostname(be2, dns, AF_INET,
+               "127.0.0.1", listener_port));
+       /* Launch an async resolve that will succeed. */
+       tt_assert(!bufferevent_socket_connect_hostname(be3, dns, AF_INET,
+               "nobodaddy.example.com", listener_port));
 
        event_base_dispatch(data->base);