diff --git a/res_send.c b/res_send.c index f391fb4..8de4637 100644 --- a/res_send.c +++ b/res_send.c @@ -959,6 +959,27 @@ vc_same_ns: return DNS_RES_STATUS_CONNECTION_REFUSED; } +#ifdef DARLING + /* + * darling-lol: the TCP (VC) reply read below is a plain + * blocking read() with no deadline. If the server is slow or + * drops the connection without RST, it blocks forever and the + * whole getaddrinfo() caller hangs (observed: RC launcher + * stall on clientconfig.rpg.riotgames.com, thread parked in + * _sys_read <- _dns_res_send <- _res_9_nsend_2). Bound it so a + * stalled server falls through to the normal retry/next-server + * path instead of wedging the process. + */ + { + struct timeval tv; + tv.tv_sec = statp->retrans > 0 ? statp->retrans : RES_TIMEOUT; + if (tv.tv_sec > 30) tv.tv_sec = 30; + tv.tv_usec = 0; + setsockopt(statp->_vcsock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + setsockopt(statp->_vcsock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); + } +#endif + statp->_flags |= RES_F_VC; }