diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index e56c7b19d..ffe0701ac 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -1159,7 +1159,9 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg) count += tmp; } - handles[count++] = WTSVirtualChannelManagerGetEventHandle(context->vcm); + + HANDLE channelHandle = WTSVirtualChannelManagerGetEventHandle(context->vcm); + handles[count++] = channelHandle; status = WaitForMultipleObjects(count, handles, FALSE, INFINITE); if (status == WAIT_FAILED) @@ -1172,6 +1174,9 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg) if (client->CheckFileDescriptor(client) != TRUE) break; + if (WaitForSingleObject(channelHandle, 0) != WAIT_OBJECT_0) + continue; + if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE) break;