mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Make sure threads dont exit on spurious return values from recvfrom unless we are really dying.
This commit is contained in:
parent
50009fef6f
commit
624efde7e4
1 changed files with 7 additions and 3 deletions
|
@ -694,7 +694,10 @@ static int bindSocket(struct sockaddr *const bindAddr)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shutdownSigHandler(int sig) { s_run = false; }
|
static void shutdownSigHandler(int sig)
|
||||||
|
{
|
||||||
|
s_run = false;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc,char **argv)
|
int main(int argc,char **argv)
|
||||||
{
|
{
|
||||||
|
@ -918,7 +921,7 @@ int main(int argc,char **argv)
|
||||||
printf("WARNING: unexpected exception handling packet from %s: unknown exception" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in6)->toString(ipstr));
|
printf("WARNING: unexpected exception handling packet from %s: unknown exception" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in6)->toString(ipstr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((errno != EAGAIN)&&(errno != EWOULDBLOCK)) {
|
} else if (!s_run) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,7 +950,7 @@ int main(int argc,char **argv)
|
||||||
printf("WARNING: unexpected exception handling packet from %s: unknown exception" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in4)->toString(ipstr));
|
printf("WARNING: unexpected exception handling packet from %s: unknown exception" ZT_EOL_S,reinterpret_cast<const InetAddress *>(&in4)->toString(ipstr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((errno != EAGAIN)&&(errno != EWOULDBLOCK)) {
|
} else if (!s_run) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1292,6 +1295,7 @@ int main(int argc,char **argv)
|
||||||
|
|
||||||
// If we received a kill signal, close everything and wait
|
// If we received a kill signal, close everything and wait
|
||||||
// for threads to die before exiting.
|
// for threads to die before exiting.
|
||||||
|
s_run = false; // sanity check
|
||||||
apiServ.stop();
|
apiServ.stop();
|
||||||
for(auto s=sockets.begin();s!=sockets.end();++s) {
|
for(auto s=sockets.begin();s!=sockets.end();++s) {
|
||||||
shutdown(*s,SHUT_RDWR);
|
shutdown(*s,SHUT_RDWR);
|
||||||
|
|
Loading…
Add table
Reference in a new issue