Fix problem where Stubby stops listening to UDP on Win10.

Winsock can return ECONNRESET when receiving UDP via recvfrom() if an ICMP Port Unreachable has been received. Rather than treat the socket as being in error and closing it, just ignore the error.
This commit is contained in:
Jim Hague 2017-10-04 17:42:06 +01:00
parent 757becc812
commit 1eae1ad96b
1 changed files with 8 additions and 0 deletions

View File

@ -544,6 +544,14 @@ static void udp_read_cb(void *userarg)
conn->addrlen = sizeof(conn->remote_in);
if ((len = recvfrom(l->fd, (void *)buf, sizeof(buf), 0,
(struct sockaddr *)&conn->remote_in, &conn->addrlen)) == -1) {
if (_getdns_socketerror() == _getdns_ECONNRESET) {
/*
* WINSOCK gives ECONNRESET on ICMP Port Unreachable
* being received. Ignore it.
* */
GETDNS_FREE(*mf, conn);
return;
}
/* IO error, cleanup this listener. */
loop->vmt->clear(loop, &l->event);
_getdns_closesocket(l->fd);