transport/mfreerdp: fix async transport
- handle WAIT_TIMEOUT result as error in async transport thread if an INFINITE timeout was specified in WaitForMultipleObjects - fix mfreerdp's async transport handling to not use freerdp_get_event_handles/freerdp_check_event_handles if async transport is activated
This commit is contained in:
parent
7220e34b5b
commit
51b697d4c8
@ -164,14 +164,14 @@ DWORD mac_client_thread(void* param)
|
||||
@autoreleasepool
|
||||
{
|
||||
int status;
|
||||
HANDLE events[4];
|
||||
HANDLE events[16];
|
||||
HANDLE inputEvent;
|
||||
HANDLE inputThread = NULL;
|
||||
HANDLE updateEvent;
|
||||
HANDLE updateThread = NULL;
|
||||
HANDLE channelsEvent;
|
||||
|
||||
DWORD nCount;
|
||||
DWORD nCountTmp;
|
||||
DWORD nCountBase;
|
||||
rdpContext* context = (rdpContext*) param;
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
freerdp* instance = context->instance;
|
||||
@ -202,7 +202,12 @@ DWORD mac_client_thread(void* param)
|
||||
}
|
||||
else
|
||||
{
|
||||
events[nCount++] = updateEvent = freerdp_get_message_queue_event_handle(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
|
||||
if (!(updateEvent = freerdp_get_message_queue_event_handle(instance, FREERDP_UPDATE_MESSAGE_QUEUE)))
|
||||
{
|
||||
WLog_ERR(TAG, "failed to get update event handle");
|
||||
goto disconnect;
|
||||
}
|
||||
events[nCount++] = updateEvent;
|
||||
}
|
||||
|
||||
if (settings->AsyncInput)
|
||||
@ -215,17 +220,41 @@ DWORD mac_client_thread(void* param)
|
||||
}
|
||||
else
|
||||
{
|
||||
events[nCount++] = inputEvent = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE);
|
||||
if (!(inputEvent = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE)))
|
||||
{
|
||||
WLog_ERR(TAG, "failed to get input event handle");
|
||||
goto disconnect;
|
||||
}
|
||||
events[nCount++] = inputEvent;
|
||||
}
|
||||
|
||||
events[nCount++] = channelsEvent = freerdp_channels_get_event_handle(instance);
|
||||
nCountBase = nCount;
|
||||
|
||||
while (1)
|
||||
while (!freerdp_shall_disconnect(instance))
|
||||
{
|
||||
nCount = nCountBase;
|
||||
|
||||
if (!settings->AsyncTransport)
|
||||
{
|
||||
if (!(nCountTmp = freerdp_get_event_handles(context, &events[nCount], 16 - nCount)))
|
||||
{
|
||||
WLog_ERR(TAG, "freerdp_get_event_handles failed");
|
||||
break;
|
||||
}
|
||||
nCount += nCountTmp;
|
||||
}
|
||||
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
|
||||
if (WaitForSingleObject(mfc->stopEvent, 0) == WAIT_OBJECT_0)
|
||||
if (status >= (WAIT_OBJECT_0 + nCount))
|
||||
{
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed (0x%08X)", status);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
{
|
||||
/* stop event triggered */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -245,9 +274,13 @@ DWORD mac_client_thread(void* param)
|
||||
}
|
||||
}
|
||||
|
||||
if (WaitForSingleObject(channelsEvent, 0) == WAIT_OBJECT_0)
|
||||
if (!settings->AsyncTransport)
|
||||
{
|
||||
freerdp_channels_process_pending_messages(instance);
|
||||
if (!freerdp_check_event_handles(context))
|
||||
{
|
||||
WLog_ERR(TAG, "freerdp_check_event_handles failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -876,6 +876,7 @@ static void* transport_client_thread(void* arg)
|
||||
DWORD dwExitCode = 0;
|
||||
DWORD status;
|
||||
DWORD nCount;
|
||||
DWORD nCountTmp;
|
||||
HANDLE handles[64];
|
||||
rdpTransport* transport = (rdpTransport*) arg;
|
||||
rdpContext* context = transport->context;
|
||||
@ -907,14 +908,14 @@ static void* transport_client_thread(void* arg)
|
||||
|
||||
while (1)
|
||||
{
|
||||
handles[0] = transport->stopEvent;
|
||||
nCount = 1; /* transport->stopEvent */
|
||||
|
||||
if (!(nCount = freerdp_get_event_handles(context, &handles[1], 63)))
|
||||
if (!(nCountTmp = freerdp_get_event_handles(context, &handles[nCount], 64 - nCount)))
|
||||
{
|
||||
WLog_ERR(TAG, "freerdp_get_event_handles failed");
|
||||
break;
|
||||
}
|
||||
nCount++;
|
||||
nCount += nCountTmp;
|
||||
|
||||
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
|
||||
|
||||
@ -940,13 +941,9 @@ static void* transport_client_thread(void* arg)
|
||||
else
|
||||
{
|
||||
if (status == WAIT_TIMEOUT)
|
||||
{
|
||||
/* This happens quite frequently although we've specified an INFINITE timeout
|
||||
* WaitForMultipleObjects bug ?
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with status 0x%08X", status);
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects returned WAIT_TIMEOUT");
|
||||
else
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects returned 0x%08X", status);
|
||||
dwExitCode = 1;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user