summaryrefslogtreecommitdiff
path: root/util/event_notifier-posix.c
diff options
context:
space:
mode:
authorGal Hammer <ghammer@redhat.com>2018-01-14 12:06:54 +0200
committerMichael S. Tsirkin <mst@redhat.com>2018-01-18 21:52:37 +0200
commitf87d72f5c5bff0837d409a56bd34f439a90119ca (patch)
treea82bcc163baf18a766707e5eb7affcae77fa9b36 /util/event_notifier-posix.c
parent406d2aa2cc0770526081da00780ed2124cff1654 (diff)
downloadqemu-f87d72f5c5bff0837d409a56bd34f439a90119ca.tar.gz
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: Gal Hammer <ghammer@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'util/event_notifier-posix.c')
-rw-r--r--util/event_notifier-posix.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 73c4046b58..652566634a 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -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)