Allow the input queue to drain before terminating the thread

This ensures any final input messages (like key ups) make it to the host
This commit is contained in:
Cameron Gutman
2021-05-15 22:01:50 -05:00
parent 71c9ff0d91
commit 431e188b07
3 changed files with 57 additions and 17 deletions

View File

@@ -361,14 +361,15 @@ int stopInputStream(void) {
// No more packets should be queued now
initialized = false;
// Signal the input send thread
LbqSignalQueueShutdown(&packetQueue);
PltInterruptThread(&inputSendThread);
// Signal the input send thread to drain all pending
// input packets before shutting down.
LbqSignalQueueDrain(&packetQueue);
if (inputSock != INVALID_SOCKET) {
shutdownTcpSocket(inputSock);
}
PltInterruptThread(&inputSendThread);
PltJoinThread(&inputSendThread);
PltCloseThread(&inputSendThread);