Skip to content

Commit

Permalink
Merge branch 'regress-dns-fixes'
Browse files Browse the repository at this point in the history
* regress-dns-fixes:
  Do not rely on getservbyname() for most of the dns regression tests
  Turn off dns/getaddrinfo_race_gotresolve by default
  Fix an error for debug locking in dns/getaddrinfo_race_gotresolve
  • Loading branch information
azat committed Oct 21, 2018
2 parents 9591875 + 2cb8eae commit bd2184d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/regress_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ dns_client_fail_requests_getaddrinfo_test(void *arg)
tt_assert(!evdns_base_nameserver_ip_add(dns, buf));

for (i = 0; i < 20; ++i)
tt_assert(evdns_getaddrinfo(dns, "foof.example.com", "ssh", NULL, getaddrinfo_cb, &r[i]));
tt_assert(evdns_getaddrinfo(dns, "foof.example.com", "80", NULL, getaddrinfo_cb, &r[i]));

n_replies_left = 20;
exit_base = base;
Expand All @@ -2139,6 +2139,8 @@ struct race_param
volatile int stopping;
void *base;
void *dns;

int locked;
};
static void *
race_base_run(void *arg)
Expand Down Expand Up @@ -2231,9 +2233,10 @@ getaddrinfo_race_gotresolve_test(void *arg)
}

EVLOCK_LOCK(rp.lock, 0);
rp.locked = 1;

for (i = 0; i < n_reqs; ++i) {
tt_assert(evdns_getaddrinfo(rp.dns, "foof.example.com", "ssh", NULL, race_gai_cb, &rp));
tt_assert(evdns_getaddrinfo(rp.dns, "foof.example.com", "80", NULL, race_gai_cb, &rp));
// This magic along with busy-wait threads make this thread yield frequently
if (i % 100 == 0) {
tv.tv_sec = 0;
Expand All @@ -2256,12 +2259,15 @@ getaddrinfo_race_gotresolve_test(void *arg)
tt_assert(EVTHREAD_COND_WAIT_TIMED(rp.bw_threads_exited_cond, rp.lock, &tv) == 0);

EVLOCK_UNLOCK(rp.lock, 0);
rp.locked = 0;

evdns_base_free(rp.dns, 1 /** fail requests */);

tt_int_op(n_replies_left, ==, 0);

end:
if (rp.locked)
EVLOCK_UNLOCK(rp.lock, 0);
EVTHREAD_FREE_LOCK(rp.lock, 0);
EVTHREAD_FREE_COND(rp.reqs_cmpl_cond);
EVTHREAD_FREE_COND(rp.bw_threads_exited_cond);
Expand Down Expand Up @@ -2330,7 +2336,7 @@ struct testcase_t dns_testcases[] = {
#ifdef EVTHREAD_USE_PTHREADS_IMPLEMENTED
{ "getaddrinfo_race_gotresolve",
getaddrinfo_race_gotresolve_test,
TT_FORK, NULL, NULL },
TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL },
#endif

END_OF_TESTCASES
Expand Down

0 comments on commit bd2184d

Please sign in to comment.