/* === Test for bufferevent_socket_connect_hostname */
static int total_connected_or_failed = 0;
+static int total_n_accepted = 0;
static struct event_base *be_connect_hostname_base = NULL;
/* Implements a DNS server for the connect_hostname test and the
{
int *p = arg;
(*p)++;
+ ++total_n_accepted;
/* don't do anything with the socket; let it close when we exit() */
+ if (total_n_accepted >= 3 && total_connected_or_failed >= 5)
+ event_base_loopexit(be_connect_hostname_base,
+ NULL);
}
struct be_conn_hostname_result {
if ((what & BEV_EVENT_CONNECTED) || (what & BEV_EVENT_ERROR)) {
int r;
- ++total_connected_or_failed;
- TT_BLATHER(("Got %d connections or errors.", total_connected_or_failed));
if ((r = bufferevent_socket_get_dns_error(bev))) {
got->dnserr = r;
TT_BLATHER(("DNS error %d: %s", r,
evutil_gai_strerror(r)));
- }
- if (total_connected_or_failed >= 5)
+ } ++total_connected_or_failed;
+ TT_BLATHER(("Got %d connections or errors.", total_connected_or_failed));
+
+ if (total_n_accepted >= 3 && total_connected_or_failed >= 5)
event_base_loopexit(be_connect_hostname_base,
NULL);
}