Browse Source

Handle WSAECONNRESET to avoid stopping the supernode on Windows

pull/100/head
emanuele-f 6 years ago
parent
commit
03761fc84c
  1. 10
      edge_utils.c
  2. 9
      sn.c

10
edge_utils.c

@ -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

@ -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;
}

Loading…
Cancel
Save