Kill TCP sockets in 2 stages to fix a race condition during socket closure

This commit is contained in:
Cameron Gutman
2016-02-15 17:26:34 -05:00
parent c18e334cd4
commit e5a6297d30
5 changed files with 23 additions and 13 deletions

View File

@@ -392,19 +392,23 @@ int stopControlStream(void) {
LbqSignalQueueShutdown(&invalidReferenceFrameTuples);
PltSetEvent(&invalidateRefFramesEvent);
if (ctlSock != INVALID_SOCKET) {
shutdownSocket(ctlSock);
}
PltInterruptThread(&lossStatsThread);
PltInterruptThread(&invalidateRefFramesThread);
if (ctlSock != INVALID_SOCKET) {
closeSocket(ctlSock);
ctlSock = INVALID_SOCKET;
}
PltJoinThread(&lossStatsThread);
PltJoinThread(&invalidateRefFramesThread);
PltCloseThread(&lossStatsThread);
PltCloseThread(&invalidateRefFramesThread);
if (ctlSock != INVALID_SOCKET) {
closeSocket(ctlSock);
ctlSock = INVALID_SOCKET;
}
return 0;
}