Handle WSAECONNRESET to avoid stopping the supernode on Windows

This commit is contained in:
emanuele-f 2019-03-27 01:13:58 +01:00
parent 03dbedd52b
commit 03761fc84c
2 changed files with 17 additions and 2 deletions

View File

@ -1311,7 +1311,15 @@ static void readFromIPSocket(n2n_edge_t * eee, int in_sock) {
(struct sockaddr *)&sender_sock, (socklen_t*)&i);
if(recvlen < 0) {
traceEvent(TRACE_ERROR, "recvfrom failed with %s", strerror(errno));
#ifdef WIN32
if(WSAGetLastError() != WSAECONNRESET)
#endif
{
traceEvent(TRACE_ERROR, "recvfrom() failed %d errno %d (%s)", recvlen, errno, strerror(errno));
#ifdef WIN32
traceEvent(TRACE_ERROR, "WSAGetLastError(): %u", WSAGetLastError());
#endif
}
return; /* failed to receive data from UDP */
}

9
sn.c
View File

@ -968,10 +968,17 @@ static int run_loop(n2n_sn_t * sss) {
bread = recvfrom(sss->sock, pktbuf, N2N_SN_PKTBUF_SIZE, 0/*flags*/,
(struct sockaddr *)&sender_sock, (socklen_t*)&i);
if(bread < 0) {
if((bread < 0)
#ifdef WIN32
&& (WSAGetLastError() != WSAECONNRESET)
#endif
) {
/* For UDP bread of zero just means no data (unlike TCP). */
/* The fd is no good now. Maybe we lost our interface. */
traceEvent(TRACE_ERROR, "recvfrom() failed %d errno %d (%s)", bread, errno, strerror(errno));
#ifdef WIN32
traceEvent(TRACE_ERROR, "WSAGetLastError(): %u", WSAGetLastError());
#endif
keep_running=0;
break;
}