Refactored channel error handling

* Fix WINPR_ASSERT if a client can not allocate new resources,
  terminated cleanly instead.
* Add WINPR_ASSERT for lots of channel arguments
This commit is contained in:
Armin Novak
2021-09-06 16:46:01 +02:00
committed by akallabeth
parent cde002f460
commit 95ecc6929a
8 changed files with 151 additions and 106 deletions

View File

@@ -1175,18 +1175,23 @@ static UINT encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
if (encomsp->OpenHandle == 0)
return CHANNEL_RC_OK;
if (MessageQueue_PostQuit(encomsp->queue, 0) &&
(WaitForSingleObject(encomsp->thread, INFINITE) == WAIT_FAILED))
if (encomsp->queue && encomsp->thread)
{
rc = GetLastError();
WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
return rc;
if (MessageQueue_PostQuit(encomsp->queue, 0) &&
(WaitForSingleObject(encomsp->thread, INFINITE) == WAIT_FAILED))
{
rc = GetLastError();
WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
return rc;
}
}
MessageQueue_Free(encomsp->queue);
CloseHandle(encomsp->thread);
encomsp->queue = NULL;
encomsp->thread = NULL;
WINPR_ASSERT(encomsp->channelEntryPoints.pVirtualChannelCloseEx);
rc = encomsp->channelEntryPoints.pVirtualChannelCloseEx(encomsp->InitHandle,
encomsp->OpenHandle);