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);
psPeerInitialize Initialize;
psPeerGetFileDescriptor GetFileDescriptor;
- psPeerGetEventHandle GetEventHandle;
+ psPeerGetEventHandles GetEventHandles;
psPeerGetReceiveEventHandle GetReceiveEventHandle;
psPeerCheckFileDescriptor CheckFileDescriptor;
psPeerClose Close;
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;
}
-static HANDLE freerdp_peer_get_event_handle(freerdp_peer* client)
+static DWORD freerdp_peer_get_event_handles(freerdp_peer* client, HANDLE* events, DWORD count)
{
- HANDLE hEvent = NULL;
- rdpTransport* transport = client->context->rdp->transport;
- BIO_get_event(transport->frontBio, &hEvent);
- return hEvent;
+ DWORD nCount = 0;
+ nCount += transport_get_event_handles(client->context->rdp->transport, events, count);
+
+ if (nCount == 0)
+ return 0;
+
+ return nCount;
}
static BOOL freerdp_peer_check_fds(freerdp_peer* peer)
client->ContextSize = sizeof(rdpContext);
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;
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);
wMessage pointerAlphaMsg;
wMessage audioVolumeMsg;
HANDLE events[32];
- HANDLE ClientEvent;
HANDLE ChannelEvent;
void* UpdateSubscriber;
HANDLE UpdateEvent;
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);
(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 */