summaryrefslogtreecommitdiff
path: root/source4/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/events')
-rw-r--r--source4/lib/events/events.c14
-rw-r--r--source4/lib/events/events.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c
index 83b013f366..b6ba79430c 100644
--- a/source4/lib/events/events.c
+++ b/source4/lib/events/events.c
@@ -153,3 +153,17 @@ int event_loop_wait(struct event_context *ev)
{
return ev->ops->loop_wait(ev);
}
+
+/*
+ find an event context that is a parent of the given memory context,
+ or create a new event context as a child of the given context if
+ none is found
+*/
+struct event_context *event_context_find(TALLOC_CTX *mem_ctx)
+{
+ struct event_context *ev = talloc_find_parent_bytype(mem_ctx, struct event_context);
+ if (ev == NULL) {
+ ev = event_context_init(mem_ctx);
+ }
+ return ev;
+}
diff --git a/source4/lib/events/events.h b/source4/lib/events/events.h
index 794407204b..3570229715 100644
--- a/source4/lib/events/events.h
+++ b/source4/lib/events/events.h
@@ -49,6 +49,8 @@ int event_loop_wait(struct event_context *ev);
uint16_t event_get_fd_flags(struct fd_event *fde);
void event_set_fd_flags(struct fd_event *fde, uint16_t flags);
+struct event_context *event_context_find(TALLOC_CTX *mem_ctx);
+
/* bits for file descriptor event flags */
#define EVENT_FD_READ 1
#define EVENT_FD_WRITE 2