mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-core: return proper event handles on Windows
This commit is contained in:
parent
c8173c405d
commit
8c746976bb
|
@ -1262,13 +1262,13 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan
|
||||||
BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** read_fds,
|
BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** read_fds,
|
||||||
int* read_count, void** write_fds, int* write_count)
|
int* read_count, void** write_fds, int* write_count)
|
||||||
{
|
{
|
||||||
int fd;
|
void* pfd;
|
||||||
|
|
||||||
fd = GetEventFileDescriptor(channels->signal);
|
pfd = GetEventWaitObject(channels->signal);
|
||||||
|
|
||||||
if (fd != -1)
|
if (pfd)
|
||||||
{
|
{
|
||||||
read_fds[*read_count] = ((void*) (long) fd);
|
read_fds[*read_count] = pfd;
|
||||||
(*read_count)++;
|
(*read_count)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -469,23 +469,23 @@ void WTSDestroyVirtualChannelManager(WTSVirtualChannelManager* vcm)
|
||||||
void WTSVirtualChannelManagerGetFileDescriptor(WTSVirtualChannelManager* vcm,
|
void WTSVirtualChannelManagerGetFileDescriptor(WTSVirtualChannelManager* vcm,
|
||||||
void** fds, int* fds_count)
|
void** fds, int* fds_count)
|
||||||
{
|
{
|
||||||
int fd;
|
void* fd;
|
||||||
|
|
||||||
fd = GetEventFileDescriptor(vcm->send_event);
|
fd = GetEventWaitObject(vcm->send_event);
|
||||||
|
|
||||||
if (fd != -1)
|
if (fd)
|
||||||
{
|
{
|
||||||
fds[*fds_count] = ((void*) (long) fd);
|
fds[*fds_count] = fd;
|
||||||
(*fds_count)++;
|
(*fds_count)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcm->drdynvc_channel)
|
if (vcm->drdynvc_channel)
|
||||||
{
|
{
|
||||||
fd = GetEventFileDescriptor(vcm->drdynvc_channel->receive_event);
|
fd = GetEventWaitObject(vcm->drdynvc_channel->receive_event);
|
||||||
|
|
||||||
if (fd != -1)
|
if (fd)
|
||||||
{
|
{
|
||||||
fds[*fds_count] = ((void*) (long) fd);
|
fds[*fds_count] = fd;
|
||||||
(*fds_count)++;
|
(*fds_count)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ BOOL WTSVirtualChannelQuery(
|
||||||
/* __out */ void** ppBuffer,
|
/* __out */ void** ppBuffer,
|
||||||
/* __out */ UINT32* pBytesReturned)
|
/* __out */ UINT32* pBytesReturned)
|
||||||
{
|
{
|
||||||
int fd;
|
void* pfd;
|
||||||
BOOL bval;
|
BOOL bval;
|
||||||
void* fds[10];
|
void* fds[10];
|
||||||
int fds_count = 0;
|
int fds_count = 0;
|
||||||
|
@ -637,11 +637,11 @@ BOOL WTSVirtualChannelQuery(
|
||||||
{
|
{
|
||||||
case WTSVirtualFileHandle:
|
case WTSVirtualFileHandle:
|
||||||
|
|
||||||
fd = GetEventFileDescriptor(channel->receive_event);
|
pfd = GetEventWaitObject(channel->receive_event);
|
||||||
|
|
||||||
if (fd != -1)
|
if (pfd)
|
||||||
{
|
{
|
||||||
fds[fds_count] = ((void*) (long) fd);
|
fds[fds_count] = pfd;
|
||||||
(fds_count)++;
|
(fds_count)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,7 @@ int transport_write(rdpTransport* transport, STREAM* s)
|
||||||
|
|
||||||
void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount)
|
void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount)
|
||||||
{
|
{
|
||||||
int fd;
|
void* pfd;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
rfds[*rcount] = transport->TcpIn->wsa_event;
|
rfds[*rcount] = transport->TcpIn->wsa_event;
|
||||||
|
@ -537,11 +537,11 @@ void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fd = GetEventFileDescriptor(transport->recv_event);
|
pfd = GetEventWaitObject(transport->recv_event);
|
||||||
|
|
||||||
if (fd != -1)
|
if (pfd)
|
||||||
{
|
{
|
||||||
rfds[*rcount] = ((void*) (long) fd);
|
rfds[*rcount] = pfd;
|
||||||
(*rcount)++;
|
(*rcount)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,13 +259,14 @@ WINPR_API HANDLE CreateFileDescriptorEventW(LPSECURITY_ATTRIBUTES lpEventAttribu
|
||||||
WINPR_API HANDLE CreateFileDescriptorEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
|
WINPR_API HANDLE CreateFileDescriptorEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
|
||||||
BOOL bManualReset, BOOL bInitialState, int FileDescriptor);
|
BOOL bManualReset, BOOL bInitialState, int FileDescriptor);
|
||||||
|
|
||||||
WINPR_API int GetEventFileDescriptor(HANDLE hEvent);
|
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
#define CreateFileDescriptorEvent CreateFileDescriptorEventW
|
#define CreateFileDescriptorEvent CreateFileDescriptorEventW
|
||||||
#else
|
#else
|
||||||
#define CreateFileDescriptorEvent CreateFileDescriptorEventA
|
#define CreateFileDescriptorEvent CreateFileDescriptorEventA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WINPR_API int GetEventFileDescriptor(HANDLE hEvent);
|
||||||
|
WINPR_API void* GetEventWaitObject(HANDLE hEvent);
|
||||||
|
|
||||||
#endif /* WINPR_SYNCH_H */
|
#endif /* WINPR_SYNCH_H */
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,11 @@ HANDLE CreateFileDescriptorEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL
|
||||||
return CreateFileDescriptorEventW(lpEventAttributes, bManualReset, bInitialState, FileDescriptor);
|
return CreateFileDescriptorEventW(lpEventAttributes, bManualReset, bInitialState, FileDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns inner file descriptor for usage with select()
|
||||||
|
* This file descriptor is not usable on Windows
|
||||||
|
*/
|
||||||
|
|
||||||
int GetEventFileDescriptor(HANDLE hEvent)
|
int GetEventFileDescriptor(HANDLE hEvent)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -218,3 +223,26 @@ int GetEventFileDescriptor(HANDLE hEvent)
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns platform-specific wait object as a void pointer
|
||||||
|
*
|
||||||
|
* On Windows, the returned object is the same as the hEvent
|
||||||
|
* argument and is an event HANDLE usable in WaitForMultipleObjects
|
||||||
|
*
|
||||||
|
* On other platforms, the returned object can be cast to an int
|
||||||
|
* to obtain a file descriptor usable in select()
|
||||||
|
*/
|
||||||
|
|
||||||
|
void* GetEventWaitObject(HANDLE hEvent)
|
||||||
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = GetEventFileDescriptor(hEvent);
|
||||||
|
|
||||||
|
return ((void*) (long) fd);
|
||||||
|
#else
|
||||||
|
return hEvent;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue