Using new handle cleanup structure

This commit is contained in:
Armin Novak 2015-03-11 17:57:01 +01:00
parent 3b983476fb
commit b03356f880
1 changed files with 8 additions and 8 deletions

View File

@ -28,9 +28,6 @@
#include <pthread.h> #include <pthread.h>
static HANDLE_CLOSE_CB _NoneHandleCloseCb;
static pthread_once_t none_initialized = PTHREAD_ONCE_INIT;
static BOOL NoneHandleCloseHandle(HANDLE handle) static BOOL NoneHandleCloseHandle(HANDLE handle)
{ {
WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*) handle; WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*) handle;
@ -51,11 +48,12 @@ static BOOL NoneHandleIsHandle(HANDLE handle)
return TRUE; return TRUE;
} }
static void NoneHandleInitialize(void) static int NoneHandleGetFd(HANDLE handle)
{ {
_NoneHandleCloseCb.IsHandled = NoneHandleIsHandle; if (!NoneHandleIsHandle(handle))
_NoneHandleCloseCb.CloseHandle = NoneHandleCloseHandle; return -1;
RegisterHandleCloseCb(&_NoneHandleCloseCb);
return -1;
} }
HANDLE CreateNoneHandle() HANDLE CreateNoneHandle()
@ -66,7 +64,9 @@ HANDLE CreateNoneHandle()
if (!none) if (!none)
return NULL; return NULL;
pthread_once(&none_initialized, NoneHandleInitialize); none->cb.IsHandled = NoneHandleIsHandle;
none->cb.CloseHandle = NoneHandleCloseHandle;
none->cb.GetFd = NoneHandleGetFd;
return (HANDLE)none; return (HANDLE)none;
} }