summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/events/events.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c
index 408fe8c6f1..64cf8f41bf 100644
--- a/source4/lib/events/events.c
+++ b/source4/lib/events/events.c
@@ -113,6 +113,21 @@ struct event_context {
/*
+ destroy an event context
+*/
+static int event_context_destructor(void *ptr)
+{
+#if WITH_EPOLL
+ struct event_context *ev = talloc_get_type(ptr, struct event_context);
+ if (ev->epoll_fd != -1) {
+ close(ev->epoll_fd);
+ ev->epoll_fd = -1;
+ }
+#endif
+ return 0;
+}
+
+/*
create a event_context structure. This must be the first events
call, and all subsequent calls pass this event_context as the first
element. Event handlers also receive this as their first argument.
@@ -128,6 +143,8 @@ struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
ev->epoll_fd = epoll_create(64);
#endif
+ talloc_set_destructor(ev, event_context_destructor);
+
return ev;
}