summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-10 03:16:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:37 -0500
commit22adab2004d56918b40fff0f0716d8a889c9f007 (patch)
tree1781768988c250279fbc3ca3af6564e979cd5bc7 /source4
parent1ac4f562e2b77ba7b76028a06427ec8aeecb0df1 (diff)
downloadsamba-22adab2004d56918b40fff0f0716d8a889c9f007.tar.gz
samba-22adab2004d56918b40fff0f0716d8a889c9f007.tar.bz2
samba-22adab2004d56918b40fff0f0716d8a889c9f007.zip
r5292: ensure we cleanup the epoll_fd on event context destruction
(This used to be commit e820fca5062026810c5bd4827941f34c19a5e847)
Diffstat (limited to 'source4')
-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;
}