mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-21 22:46:54 +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;
|
||||
}
|
||||
|
||||
static void shutdownSigHandler(int sig) { s_run = false; }
|
||||
static void shutdownSigHandler(int sig)
|
||||
{
|
||||
s_run = false;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
} else if ((errno != EAGAIN)&&(errno != EWOULDBLOCK)) {
|
||||
} else if (!s_run) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
} else if ((errno != EAGAIN)&&(errno != EWOULDBLOCK)) {
|
||||
} else if (!s_run) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1292,6 +1295,7 @@ int main(int argc,char **argv)
|
|||
|
||||
// If we received a kill signal, close everything and wait
|
||||
// for threads to die before exiting.
|
||||
s_run = false; // sanity check
|
||||
apiServ.stop();
|
||||
for(auto s=sockets.begin();s!=sockets.end();++s) {
|
||||
shutdown(*s,SHUT_RDWR);
|
||||
|
|
Loading…
Add table
Reference in a new issue