diff --git a/src/dns.c b/src/dns.c index 15ff335..3f91897 100644 --- a/src/dns.c +++ b/src/dns.c @@ -6596,6 +6596,11 @@ int dns_so_check(struct dns_socket *so) { case DNS_SO_UDP_INIT: so->state++; case DNS_SO_UDP_CONN: +#if __linux + /* work-around for https://github.com/wahern/dns/issues/19 */ + if (so->stat.udp.sent.count) + connect(so->udp, &(struct sockaddr){.sa_family = AF_UNSPEC}, sizeof(struct sockaddr)); +#endif if (0 != connect(so->udp, (struct sockaddr *)&so->remote, dns_sa_len(&so->remote))) goto soerr; @@ -7537,8 +7542,11 @@ static int dns_res_exec(struct dns_resolver *R) { if (dns_so_elapsed(&R->so) >= dns_resconf_timeout(R->resconf)) dgoto(R->sp, DNS_R_FOREACH_A); - if ((error = dns_so_check(&R->so))) + error = dns_so_check(&R->so); + if (error == EAGAIN) goto error; + if (error) + dgoto(R->sp, DNS_R_FOREACH_A); if (!dns_p_setptr(&F->answer, dns_so_fetch(&R->so, &error))) goto error;