From 71924958bd5c05327883c6065bb92715acc55be9 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 8 Feb 2019 09:05:59 +0100 Subject: [PATCH] Added event name to handle. --- winpr/libwinpr/synch/event.c | 22 +++++++++++++++++----- winpr/libwinpr/synch/synch.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index fc5681b..1b4d5c0 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -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; } diff --git a/winpr/libwinpr/synch/synch.h b/winpr/libwinpr/synch/synch.h index 0c48032..8190c48 100644 --- a/winpr/libwinpr/synch/synch.h +++ b/winpr/libwinpr/synch/synch.h @@ -68,6 +68,7 @@ typedef struct winpr_semaphore WINPR_SEMAPHORE; struct winpr_event { WINPR_HANDLE_DEF(); + char* name; int pipe_fd[2]; BOOL bAttached; -- 2.7.4