Adding a cleanup callback function to the EventNotifier struct
which allows users to execute event_notifier_cleanup in a
different context.
Signed-off-by: Gal Hammer <ghammer@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
int rfd;
int wfd;
#endif
+ void (*cleanup)(EventNotifier *);
};
typedef void EventNotifierHandler(EventNotifier *);
{
e->rfd = fd;
e->wfd = fd;
+ e->cleanup = NULL;
}
#endif
e->rfd = fds[0];
e->wfd = fds[1];
}
+ e->cleanup = NULL;
if (active) {
event_notifier_set(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)
{
e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
assert(e->event);
+ e->cleanup = NULL;
return 0;
}
{
CloseHandle(e->event);
e->event = NULL;
+ e->cleanup = NULL;
}
HANDLE event_notifier_get_handle(EventNotifier *e)