[winpr,comm] fix stopping of serial threads
Since most unhandled threads get cancelled do not rely on SERIAL_EV_WINPR_WAITING flag.
This commit is contained in:
parent
221dd7ce1d
commit
d81dd9d9ff
@ -1378,19 +1378,6 @@ BOOL CommCloseHandle(HANDLE handle)
|
||||
if (!CommIsHandled(handle))
|
||||
return FALSE;
|
||||
|
||||
if (pComm->PendingEvents & SERIAL_EV_WINPR_WAITING)
|
||||
{
|
||||
ULONG WaitMask = 0;
|
||||
DWORD BytesReturned = 0;
|
||||
|
||||
/* ensures to gracefully stop the WAIT_ON_MASK's loop */
|
||||
if (!CommDeviceIoControl(handle, IOCTL_SERIAL_SET_WAIT_MASK, &WaitMask, sizeof(ULONG), NULL,
|
||||
0, &BytesReturned, NULL))
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "failure to WAIT_ON_MASK's loop!");
|
||||
}
|
||||
}
|
||||
|
||||
DeleteCriticalSection(&pComm->ReadLock);
|
||||
DeleteCriticalSection(&pComm->WriteLock);
|
||||
DeleteCriticalSection(&pComm->EventsLock);
|
||||
|
@ -1075,6 +1075,10 @@ static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
/* waiting the end of the pending wait_on_mask() */
|
||||
while (is_wait_set(pComm))
|
||||
Sleep(10); /* 10ms */
|
||||
|
||||
EnterCriticalSection(&pComm->EventsLock);
|
||||
pComm->PendingEvents &= ~SERIAL_EV_WINPR_STOP;
|
||||
LeaveCriticalSection(&pComm->EventsLock);
|
||||
}
|
||||
|
||||
/* NB: ensure to leave the critical section before to return */
|
||||
@ -1473,8 +1477,6 @@ static BOOL wait_on_mask(WINPR_COMM* pComm, ULONG* pOutputMask)
|
||||
|
||||
if (pComm->PendingEvents & SERIAL_EV_WINPR_STOP)
|
||||
{
|
||||
pComm->PendingEvents &= ~SERIAL_EV_WINPR_STOP;
|
||||
|
||||
/* pOutputMask must remain empty but should
|
||||
* not have been modified.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user