libfreerdp-utils: replace wait_obj struct with HANDLE

This commit is contained in:
Marc-André Moreau 2012-11-26 19:21:19 -05:00
parent 57d4a07af9
commit 136282dae3
9 changed files with 37 additions and 68 deletions

View File

@ -433,7 +433,7 @@ struct rdp_channels
freerdp* instance;
/* signal for incoming data or event */
struct wait_obj* signal;
HANDLE signal;
/* used for sync write */
PSLIST_HEADER pSyncDataList;

View File

@ -62,7 +62,7 @@ struct _SERIAL_DEVICE
LIST* irp_list;
LIST* pending_irps;
freerdp_thread* thread;
struct wait_obj* in_event;
HANDLE in_event;
fd_set read_fds;
fd_set write_fds;

View File

@ -58,6 +58,7 @@ enum
};
typedef struct rdp_peer_channel rdpPeerChannel;
struct rdp_peer_channel
{
WTSVirtualChannelManager* vcm;
@ -67,7 +68,7 @@ struct rdp_peer_channel
UINT16 index;
STREAM* receive_data;
struct wait_obj* receive_event;
HANDLE receive_event;
LIST* receive_queue;
HANDLE mutex;
@ -78,7 +79,7 @@ struct rdp_peer_channel
struct WTSVirtualChannelManager
{
freerdp_peer* client;
struct wait_obj* send_event;
HANDLE send_event;
LIST* send_queue;
HANDLE mutex;

View File

@ -44,7 +44,7 @@ struct _USB_SEARCHMAN
USB_SEARCHDEV * tail; /* tail device in linked list */
pthread_mutex_t mutex;
struct wait_obj * term_event;
HANDLE term_event;
sem_t sem_term;
int strated;

View File

@ -444,8 +444,8 @@ static void* urbdrc_search_usb_device(void* arg)
IWTSVirtualChannel* dvc_channel;
USB_SEARCHDEV* sdev;
IUDEVICE* pdev = NULL;
struct wait_obj* listobj[2];
struct wait_obj* mon_fd;
HANDLE listobj[2];
HANDLE mon_fd;
int numobj, timeout;
int busnum, devnum;
int success = 0, error, on_close = 0, found = 0;

View File

@ -23,6 +23,7 @@
#include <freerdp/api.h>
#include <freerdp/types.h>
#include <freerdp/utils/wait_obj.h>
#ifndef _WIN32
#include <pthread.h>
#endif
@ -35,7 +36,7 @@ struct _freerdp_thread
{
HANDLE mutex;
struct wait_obj* signals[5];
HANDLE signals[5];
int num_signals;
int status;

View File

@ -22,13 +22,13 @@
#include <freerdp/api.h>
FREERDP_API struct wait_obj* wait_obj_new(void);
FREERDP_API struct wait_obj* wait_obj_new_with_fd(void* fd);
FREERDP_API void wait_obj_free(struct wait_obj* obj);
FREERDP_API int wait_obj_is_set(struct wait_obj* obj);
FREERDP_API void wait_obj_set(struct wait_obj* obj);
FREERDP_API void wait_obj_clear(struct wait_obj* obj);
FREERDP_API int wait_obj_select(struct wait_obj** listobj, int numobj, int timeout);
FREERDP_API void wait_obj_get_fds(struct wait_obj* obj, void** fds, int* count);
FREERDP_API HANDLE wait_obj_new(void);
FREERDP_API HANDLE wait_obj_new_with_fd(void* fd);
FREERDP_API void wait_obj_free(HANDLE event);
FREERDP_API int wait_obj_is_set(HANDLE event);
FREERDP_API void wait_obj_set(HANDLE event);
FREERDP_API void wait_obj_clear(HANDLE event);
FREERDP_API int wait_obj_select(HANDLE* events, int count, int timeout);
FREERDP_API void wait_obj_get_fds(HANDLE event, void** fds, int* count);
#endif

View File

@ -61,7 +61,7 @@ struct rdp_transport
void* recv_extra;
STREAM* recv_buffer;
TransportRecv recv_callback;
struct wait_obj* recv_event;
HANDLE recv_event;
BOOL blocking;
BOOL ProcessSinglePdu;
BOOL SplitInputOutput;

View File

@ -39,82 +39,49 @@
#include <unistd.h>
#endif
struct wait_obj
HANDLE wait_obj_new(void)
{
HANDLE event;
};
struct wait_obj* wait_obj_new(void)
{
struct wait_obj* obj;
obj = (struct wait_obj*) malloc(sizeof(struct wait_obj));
ZeroMemory(obj, sizeof(struct wait_obj));
obj->event = CreateEvent(NULL, TRUE, FALSE, NULL);
return obj;
return CreateEvent(NULL, TRUE, FALSE, NULL);
}
struct wait_obj* wait_obj_new_with_fd(void* fd)
HANDLE wait_obj_new_with_fd(void* fd)
{
struct wait_obj* obj;
obj = (struct wait_obj*) malloc(sizeof(struct wait_obj));
ZeroMemory(obj, sizeof(struct wait_obj));
obj->event = CreateFileDescriptorEvent(NULL, TRUE, FALSE, ((int) (long) fd));
return obj;
return CreateFileDescriptorEvent(NULL, TRUE, FALSE, ((int) (long) fd));
}
void wait_obj_free(struct wait_obj* obj)
void wait_obj_free(HANDLE event)
{
CloseHandle(obj->event);
CloseHandle(event);
}
int wait_obj_is_set(struct wait_obj* obj)
int wait_obj_is_set(HANDLE event)
{
return (WaitForSingleObject(obj->event, 0) == WAIT_OBJECT_0);
return (WaitForSingleObject(event, 0) == WAIT_OBJECT_0);
}
void wait_obj_set(struct wait_obj* obj)
void wait_obj_set(HANDLE event)
{
SetEvent(obj->event);
SetEvent(event);
}
void wait_obj_clear(struct wait_obj* obj)
void wait_obj_clear(HANDLE event)
{
ResetEvent(obj->event);
ResetEvent(event);
}
int wait_obj_select(struct wait_obj** listobj, int numobj, int timeout)
int wait_obj_select(HANDLE* events, int count, int timeout)
{
int index;
int status;
HANDLE* handles;
if (WaitForMultipleObjects(count, events, FALSE, timeout) == WAIT_FAILED)
return -1;
handles = (HANDLE*) malloc(sizeof(HANDLE) * (numobj + 1));
ZeroMemory(handles, sizeof(HANDLE) * (numobj + 1));
for (index = 0; index < numobj; index++)
handles[index] = listobj[index]->event;
if (WaitForMultipleObjects(numobj, handles, FALSE, timeout) == WAIT_FAILED)
status = -1;
else
status = 0;
free(handles);
return status;
return 0;
}
void wait_obj_get_fds(struct wait_obj* obj, void** fds, int* count)
void wait_obj_get_fds(HANDLE event, void** fds, int* count)
{
int fd;
fd = GetEventFileDescriptor(obj->event);
fd = GetEventFileDescriptor(event);
if (fd == -1)
return;