Handle API updated.

This commit is contained in:
Armin Novak
2015-07-03 09:36:58 +02:00
parent 77204aa6b6
commit d18b0fbeb4
15 changed files with 43 additions and 37 deletions

View File

@@ -741,7 +741,9 @@ static void* urbdrc_search_usb_device(void* arg)
/* Get the file descriptor (fd) for the monitor.
This fd will get passed to select() */
if (!(mon_fd = CreateFileDescriptorEvent(NULL, TRUE, FALSE, udev_monitor_get_fd(mon))))
mon_fd = CreateFileDescriptorEvent(NULL, TRUE, FALSE,
udev_monitor_get_fd(mon), FD_READ);
if (!mon_fd)
goto fail_create_monfd_event;
while (1)

View File

@@ -348,10 +348,12 @@ static void* jni_input_thread(void* arg)
if (!(queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE)))
goto fail_get_message_queue;
if (!(event[0] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, aCtx->event_queue->pipe_fd[0])))
if (!(event[0] = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
aCtx->event_queue->pipe_fd[0], FD_READ)))
goto fail_create_event_0;
if (!(event[1] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, aCtx->event_queue->pipe_fd[1])))
if (!(event[1] = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
aCtx->event_queue->pipe_fd[1], FD_READ)))
goto fail_create_event_1;
if (!(event[2] = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE)))

View File

@@ -1790,7 +1790,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
xfc->invert = (ImageByteOrder(xfc->display) == MSBFirst) ? TRUE : FALSE;
xfc->complex_regions = TRUE;
xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds);
xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds, FD_READ);
if (!xfc->x11event)
{
WLog_ERR(TAG, "Could not create xfds event");

View File

@@ -168,7 +168,8 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a
/* FIXME: these file descriptors do not work on Windows */
listener->sockfds[listener->num_sockfds] = sockfd;
listener->events[listener->num_sockfds] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, sockfd);
listener->events[listener->num_sockfds] =
CreateFileDescriptorEvent(NULL, FALSE, FALSE, sockfd, FD_READ);
listener->num_sockfds++;
WLog_INFO(TAG, "Listening on %s:%s", addr, servname);
@@ -226,7 +227,8 @@ static BOOL freerdp_listener_open_local(freerdp_listener* instance, const char*
return FALSE;
}
if (!(hevent = CreateFileDescriptorEvent(NULL, FALSE, FALSE, sockfd)))
hevent = CreateFileDescriptorEvent(NULL, FALSE, FALSE, sockfd, FD_READ);
if (!hevent)
{
WLog_ERR(TAG, "failed to create sockfd event");
closesocket((SOCKET) sockfd);
@@ -258,7 +260,8 @@ static BOOL freerdp_listener_open_from_socket(freerdp_listener* instance, int fd
return FALSE;
listener->sockfds[listener->num_sockfds] = fd;
listener->events[listener->num_sockfds] = CreateFileDescriptorEvent(NULL, FALSE, FALSE, fd);
listener->events[listener->num_sockfds] =
CreateFileDescriptorEvent(NULL, FALSE, FALSE, fd, FD_READ);
if (!listener->events[listener->num_sockfds])
return FALSE;

View File

@@ -368,7 +368,7 @@ static int transport_bio_simple_init(BIO* bio, SOCKET socket, int shutdown)
/* WSAEventSelect automatically sets the socket in non-blocking mode */
WSAEventSelect(ptr->socket, ptr->hEvent, FD_READ | FD_WRITE | FD_CLOSE);
#else
ptr->hEvent = CreateFileDescriptorEvent(NULL, FALSE, FALSE, (int) ptr->socket);
ptr->hEvent = CreateFileDescriptorEvent(NULL, FALSE, FALSE, (int) ptr->socket, FD_READ);
if (!ptr->hEvent)
return 0;

View File

@@ -1264,7 +1264,8 @@ int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem)
subsystem->use_xdamage = FALSE;
}
if (!(subsystem->event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, subsystem->xfds)))
if (!(subsystem->event = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
subsystem->xfds, FD_READ)))
return -1;
virtualScreen = &(subsystem->virtualScreen);

View File

@@ -1221,7 +1221,7 @@ BOOL IsCommDevice(LPCTSTR lpDeviceName)
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID driverId)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_COMM* pComm;
if (!CommInitialized())
@@ -1344,7 +1344,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
return INVALID_HANDLE_VALUE;
}
WINPR_HANDLE_SET_TYPE(pComm, HANDLE_TYPE_COMM);
WINPR_HANDLE_SET_TYPE_AND_MODE(pComm, HANDLE_TYPE_COMM, FD_READ);
pComm->ops = &ops;

View File

@@ -414,7 +414,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
}
hNamedPipe = (HANDLE) pNamedPipe;
WINPR_HANDLE_SET_TYPE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE);
WINPR_HANDLE_SET_TYPE_AND_MODE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE, FD_READ);
pNamedPipe->name = _strdup(lpFileName);
if (!pNamedPipe->name)
{
@@ -502,7 +502,6 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE *handle;
if (hFile == INVALID_HANDLE_VALUE)
@@ -516,12 +515,12 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (!lpNumberOfBytesRead && !lpOverlapped)
return FALSE;
if (!winpr_Handle_GetInfo(hFile, &Type, &Object))
if (!winpr_Handle_GetInfo(hFile, &Type, &handle))
return FALSE;
handle = (WINPR_HANDLE *)hFile;
if (handle->ops->ReadFile)
return handle->ops->ReadFile(Object, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
return handle->ops->ReadFile(handle, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
WLog_ERR(TAG, "ReadFile operation not implemented");
return FALSE;
@@ -543,18 +542,17 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE *handle;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
if (!winpr_Handle_GetInfo(hFile, &Type, &Object))
if (!winpr_Handle_GetInfo(hFile, &Type, &handle))
return FALSE;
handle = (WINPR_HANDLE *)hFile;
if (handle->ops->WriteFile)
return handle->ops->WriteFile(Object, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped);
return handle->ops->WriteFile(handle, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped);
WLog_ERR(TAG, "ReadFile operation not implemented");
return FALSE;

View File

@@ -50,7 +50,7 @@
BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
if (!winpr_Handle_GetInfo(hFile, &Type, &Object))
return FALSE;

View File

@@ -454,11 +454,11 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
pReadPipe->fd = pipe_fd[0];
pWritePipe->fd = pipe_fd[1];
WINPR_HANDLE_SET_TYPE(pReadPipe, HANDLE_TYPE_ANONYMOUS_PIPE);
WINPR_HANDLE_SET_TYPE_AND_MODE(pReadPipe, HANDLE_TYPE_ANONYMOUS_PIPE, FD_READ);
pReadPipe->ops = &ops;
*((ULONG_PTR*) hReadPipe) = (ULONG_PTR) pReadPipe;
WINPR_HANDLE_SET_TYPE(pWritePipe, HANDLE_TYPE_ANONYMOUS_PIPE);
WINPR_HANDLE_SET_TYPE_AND_MODE(pWritePipe, HANDLE_TYPE_ANONYMOUS_PIPE, FD_READ);
pWritePipe->ops = &ops;
*((ULONG_PTR*) hWritePipe) = (ULONG_PTR) pWritePipe;
return TRUE;
@@ -531,7 +531,7 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
if (!pNamedPipe)
return INVALID_HANDLE_VALUE;
WINPR_HANDLE_SET_TYPE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE);
WINPR_HANDLE_SET_TYPE_AND_MODE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE, FD_READ);
pNamedPipe->serverfd = -1;
pNamedPipe->clientfd = -1;

View File

@@ -131,7 +131,7 @@ BOOL LogonUserA(LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
if (!token)
return FALSE;
WINPR_HANDLE_SET_TYPE(token, HANDLE_TYPE_ACCESS_TOKEN);
WINPR_HANDLE_SET_TYPE_AND_MODE(token, HANDLE_TYPE_ACCESS_TOKEN, FD_READ);
token->ops = &ops;

View File

@@ -140,7 +140,7 @@ HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner,
{
pthread_mutex_init(&mutex->mutex, 0);
WINPR_HANDLE_SET_TYPE(mutex, HANDLE_TYPE_MUTEX);
WINPR_HANDLE_SET_TYPE_AND_MODE(mutex, HANDLE_TYPE_MUTEX, FD_READ);
mutex->ops = &ops;
handle = (HANDLE) mutex;
@@ -180,7 +180,7 @@ HANDLE OpenMutexW(DWORD dwDesiredAccess, BOOL bInheritHandle,LPCWSTR lpName)
BOOL ReleaseMutex(HANDLE hMutex)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_MUTEX* mutex;
if (!winpr_Handle_GetInfo(hMutex, &Type, &Object))

View File

@@ -179,7 +179,7 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti
#endif
}
WINPR_HANDLE_SET_TYPE(semaphore, HANDLE_TYPE_SEMAPHORE);
WINPR_HANDLE_SET_TYPE_AND_MODE(semaphore, HANDLE_TYPE_SEMAPHORE, FD_READ);
handle = (HANDLE) semaphore;
return handle;
}
@@ -204,7 +204,7 @@ HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_SEMAPHORE* semaphore;
if (!winpr_Handle_GetInfo(hSemaphore, &Type, &Object))

View File

@@ -230,7 +230,7 @@ HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua
timer = (WINPR_TIMER*) calloc(1, sizeof(WINPR_TIMER));
if (timer)
{
WINPR_HANDLE_SET_TYPE(timer, HANDLE_TYPE_TIMER);
WINPR_HANDLE_SET_TYPE_AND_MODE(timer, HANDLE_TYPE_TIMER, FD_READ);
handle = (HANDLE) timer;
timer->fd = -1;
timer->lPeriod = 0;
@@ -265,7 +265,7 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, BOOL fResume)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_TIMER* timer;
#ifdef WITH_POSIX_TIMER
LONGLONG seconds = 0;
@@ -365,7 +365,7 @@ BOOL SetWaitableTimerEx(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPer
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_TIMER* timer;
if (!winpr_Handle_GetInfo(hTimer, &Type, &Object))
@@ -612,7 +612,7 @@ HANDLE CreateTimerQueue(void)
if (timerQueue)
{
WINPR_HANDLE_SET_TYPE(timerQueue, HANDLE_TYPE_TIMER_QUEUE);
WINPR_HANDLE_SET_TYPE_AND_MODE(timerQueue, HANDLE_TYPE_TIMER_QUEUE, FD_READ);
handle = (HANDLE) timerQueue;
timerQueue->activeHead = NULL;
timerQueue->inactiveHead = NULL;
@@ -706,7 +706,7 @@ BOOL CreateTimerQueueTimer(PHANDLE phNewTimer, HANDLE TimerQueue,
if (!timer)
return FALSE;
WINPR_HANDLE_SET_TYPE(timer, HANDLE_TYPE_TIMER_QUEUE_TIMER);
WINPR_HANDLE_SET_TYPE_AND_MODE(timer, HANDLE_TYPE_TIMER_QUEUE_TIMER, FD_READ);
*((UINT_PTR*) phNewTimer) = (UINT_PTR)(HANDLE) timer;
timespec_copy(&(timer->StartTime), &CurrentTime);
timespec_add_ms(&(timer->StartTime), DueTime);

View File

@@ -431,7 +431,7 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
goto error_thread_ready;
}
WINPR_HANDLE_SET_TYPE(thread, HANDLE_TYPE_THREAD);
WINPR_HANDLE_SET_TYPE_AND_MODE(thread, HANDLE_TYPE_THREAD, FD_READ);
handle = (HANDLE) thread;
if (!thread_list)
@@ -613,7 +613,7 @@ VOID ExitThread(DWORD dwExitCode)
BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_THREAD* thread;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object))
@@ -665,8 +665,8 @@ DWORD GetCurrentThreadId(VOID)
DWORD ResumeThread(HANDLE hThread)
{
ULONG Type;
PVOID Object;
WINPR_THREAD *thread;
WINPR_HANDLE* Object;
WINPR_THREAD* thread;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object))
return 0;
@@ -697,7 +697,7 @@ BOOL SwitchToThread(VOID)
BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode)
{
ULONG Type;
PVOID Object;
WINPR_HANDLE* Object;
WINPR_THREAD* thread;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object))