Added event name to handle.

This commit is contained in:
Armin Novak 2019-02-08 09:05:59 +01:00
parent 55e9132fa4
commit 71924958bd
2 changed files with 18 additions and 5 deletions

View File

@ -74,11 +74,9 @@ static int EventGetFd(HANDLE handle)
return event->pipe_fd[0];
}
static BOOL EventCloseHandle(HANDLE handle)
static BOOL EventCloseHandle_(WINPR_EVENT* event)
{
WINPR_EVENT* event = (WINPR_EVENT*) handle;
if (!EventIsHandled(handle))
if (!event)
return FALSE;
if (!event->bAttached)
@ -96,10 +94,21 @@ static BOOL EventCloseHandle(HANDLE handle)
}
}
free(event->name);
free(event);
return TRUE;
}
static BOOL EventCloseHandle(HANDLE handle)
{
WINPR_EVENT* event = (WINPR_EVENT*) handle;
if (!EventIsHandled(handle))
return FALSE;
return EventCloseHandle_(event);
}
static HANDLE_OPS ops =
{
EventIsHandled,
@ -154,6 +163,9 @@ HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
if (!event)
return NULL;
if (lpName)
event->name = strdup(lpName);
event->bAttached = FALSE;
event->bManualReset = bManualReset;
event->ops = &ops;
@ -185,7 +197,7 @@ HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
return (HANDLE)event;
fail:
free(event);
EventCloseHandle_(event);
return NULL;
}

View File

@ -68,6 +68,7 @@ typedef struct winpr_semaphore WINPR_SEMAPHORE;
struct winpr_event
{
WINPR_HANDLE_DEF();
char* name;
int pipe_fd[2];
BOOL bAttached;