Merge pull request #3578 from realjiangms/fix_server_for_limit_frames

Fix server side code to be aware of rereadEvent
This commit is contained in:
David Fort 2016-11-03 22:50:08 +01:00 committed by GitHub
commit ea24c1f8e1
4 changed files with 37 additions and 13 deletions

View File

@ -35,6 +35,7 @@ typedef void (*psPeerContextFree)(freerdp_peer* peer, rdpContext* context);
typedef BOOL (*psPeerInitialize)(freerdp_peer* peer);
typedef BOOL (*psPeerGetFileDescriptor)(freerdp_peer* peer, void** rfds, int* rcount);
typedef HANDLE(*psPeerGetEventHandle)(freerdp_peer* peer);
typedef DWORD (*psPeerGetEventHandles)(freerdp_peer* peer, HANDLE* events, DWORD count);
typedef HANDLE(*psPeerGetReceiveEventHandle)(freerdp_peer* peer);
typedef BOOL (*psPeerCheckFileDescriptor)(freerdp_peer* peer);
typedef BOOL (*psPeerIsWriteBlocked)(freerdp_peer* peer);
@ -111,6 +112,7 @@ struct rdp_freerdp_peer
psPeerIsWriteBlocked IsWriteBlocked;
psPeerDrainOutputBuffer DrainOutputBuffer;
psPeerHasMoreToRead HasMoreToRead;
psPeerGetEventHandles GetEventHandles;
};
#ifdef __cplusplus

View File

@ -244,8 +244,7 @@ static BOOL freerdp_peer_initialize(freerdp_peer* client)
static BOOL freerdp_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
{
rdpTransport* transport = client->context->rdp->transport;
rfds[*rcount] = (void*)(long)(BIO_get_fd(transport->frontBio, NULL));
(*rcount)++;
transport_get_fds(transport, rfds, rcount);
return TRUE;
}
@ -257,6 +256,11 @@ static HANDLE freerdp_peer_get_event_handle(freerdp_peer* client)
return hEvent;
}
static DWORD freerdp_peer_get_event_handles(freerdp_peer* client, HANDLE* events, DWORD count)
{
return transport_get_event_handles(client->context->rdp->transport, events, count);
}
static BOOL freerdp_peer_check_fds(freerdp_peer* peer)
{
int status;
@ -806,6 +810,7 @@ freerdp_peer* freerdp_peer_new(int sockfd)
client->Initialize = freerdp_peer_initialize;
client->GetFileDescriptor = freerdp_peer_get_fds;
client->GetEventHandle = freerdp_peer_get_event_handle;
client->GetEventHandles = freerdp_peer_get_event_handles;
client->CheckFileDescriptor = freerdp_peer_check_fds;
client->Close = freerdp_peer_close;
client->Disconnect = freerdp_peer_disconnect;

View File

@ -803,7 +803,17 @@ static void* test_peer_mainloop(void* arg)
while (1)
{
count = 0;
handles[count++] = client->GetEventHandle(client);
{
DWORD tmp = client->GetEventHandles(client, &handles[count], 32 - count);
if (tmp == 0)
{
WLog_ERR(TAG, "Failed to get FreeRDP transport event handles");
break;
}
count += tmp;
}
handles[count++] = WTSVirtualChannelManagerGetEventHandle(context->vcm);
status = WaitForMultipleObjects(count, handles, FALSE, INFINITE);

View File

@ -1454,7 +1454,6 @@ static void* shadow_client_thread(rdpShadowClient* client)
wMessage pointerAlphaMsg;
wMessage audioVolumeMsg;
HANDLE events[32];
HANDLE ClientEvent;
HANDLE ChannelEvent;
void* UpdateSubscriber;
HANDLE UpdateEvent;
@ -1497,14 +1496,23 @@ static void* shadow_client_thread(rdpShadowClient* client)
goto out;
UpdateEvent = shadow_multiclient_getevent(UpdateSubscriber);
ClientEvent = peer->GetEventHandle(peer);
ChannelEvent = WTSVirtualChannelManagerGetEventHandle(client->vcm);
while (1)
{
nCount = 0;
events[nCount++] = UpdateEvent;
events[nCount++] = ClientEvent;
{
DWORD tmp = peer->GetEventHandles(peer, &events[nCount], 64 - nCount);
if (tmp == 0)
{
WLog_ERR(TAG, "Failed to get FreeRDP transport event handles");
break;
}
nCount += tmp;
}
events[nCount++] = ChannelEvent;
events[nCount++] = MessageQueue_Event(MsgQueue);
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
@ -1559,14 +1567,13 @@ static void* shadow_client_thread(rdpShadowClient* client)
(void)shadow_multiclient_consume(UpdateSubscriber);
}
if (WaitForSingleObject(ClientEvent, 0) == WAIT_OBJECT_0)
if (!peer->CheckFileDescriptor(peer))
{
WLog_ERR(TAG, "Failed to check FreeRDP file descriptor");
break;
}
else
{
if (!peer->CheckFileDescriptor(peer))
{
WLog_ERR(TAG, "Failed to check FreeRDP file descriptor");
break;
}
if (WTSVirtualChannelManagerIsChannelJoined(client->vcm, "drdynvc"))
{
/* Dynamic channel status may have been changed after processing */