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

@@ -294,12 +294,16 @@ int stopInputStream(void) {
PltInterruptThread(&inputSendThread);
if (inputSock != INVALID_SOCKET) {
closeSocket(inputSock);
inputSock = INVALID_SOCKET;
shutdownSocket(inputSock);
}
PltJoinThread(&inputSendThread);
PltCloseThread(&inputSendThread);
if (inputSock != INVALID_SOCKET) {
closeSocket(inputSock);
inputSock = INVALID_SOCKET;
}
return 0;
}