Added event name to handle.
authorArmin Novak <armin.novak@thincast.com>
Fri, 8 Feb 2019 08:05:59 +0000 (09:05 +0100)
committerArmin Novak <armin.novak@thincast.com>
Fri, 5 Apr 2019 07:14:35 +0000 (09:14 +0200)
winpr/libwinpr/synch/event.c
winpr/libwinpr/synch/synch.h

index fc5681b..1b4d5c0 100644 (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;
 }
 
index 0c48032..8190c48 100644 (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;