mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
[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))
|
if (!CommIsHandled(handle))
|
||||||
return FALSE;
|
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->ReadLock);
|
||||||
DeleteCriticalSection(&pComm->WriteLock);
|
DeleteCriticalSection(&pComm->WriteLock);
|
||||||
DeleteCriticalSection(&pComm->EventsLock);
|
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() */
|
/* waiting the end of the pending wait_on_mask() */
|
||||||
while (is_wait_set(pComm))
|
while (is_wait_set(pComm))
|
||||||
Sleep(10); /* 10ms */
|
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 */
|
/* 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)
|
if (pComm->PendingEvents & SERIAL_EV_WINPR_STOP)
|
||||||
{
|
{
|
||||||
pComm->PendingEvents &= ~SERIAL_EV_WINPR_STOP;
|
|
||||||
|
|
||||||
/* pOutputMask must remain empty but should
|
/* pOutputMask must remain empty but should
|
||||||
* not have been modified.
|
* not have been modified.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user