Commit f87d72f5 authored by Gal Hammer's avatar Gal Hammer Committed by Michael S. Tsirkin
Browse files

qemu: add a cleanup callback function to EventNotifier



Adding a cleanup callback function to the EventNotifier struct
which allows users to execute event_notifier_cleanup in a
different context.

Signed-off-by: default avatarGal Hammer <ghammer@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 406d2aa2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ struct EventNotifier {
    int rfd;
    int wfd;
#endif
    void (*cleanup)(EventNotifier *);
};

typedef void EventNotifierHandler(EventNotifier *);
+4 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ void event_notifier_init_fd(EventNotifier *e, int fd)
{
    e->rfd = fd;
    e->wfd = fd;
    e->cleanup = NULL;
}
#endif

@@ -65,6 +66,7 @@ int event_notifier_init(EventNotifier *e, int active)
        e->rfd = fds[0];
        e->wfd = fds[1];
    }
    e->cleanup = NULL;
    if (active) {
        event_notifier_set(e);
    }
@@ -80,10 +82,11 @@ void event_notifier_cleanup(EventNotifier *e)
{
    if (e->rfd != e->wfd) {
        close(e->rfd);
        e->rfd = -1;
    }
    close(e->wfd);
    e->rfd = -1;
    e->wfd = -1;
    e->cleanup = NULL;
}

int event_notifier_get_fd(const EventNotifier *e)
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ int event_notifier_init(EventNotifier *e, int active)
{
    e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
    assert(e->event);
    e->cleanup = NULL;
    return 0;
}

@@ -26,6 +27,7 @@ void event_notifier_cleanup(EventNotifier *e)
{
    CloseHandle(e->event);
    e->event = NULL;
    e->cleanup = NULL;
}

HANDLE event_notifier_get_handle(EventNotifier *e)