*/
uint16_t event_get_fd_flags(struct fd_event *fde)
{
+ if (!fde) return 0;
return fde->event_ctx->ops->get_fd_flags(fde);
}
*/
void event_set_fd_flags(struct fd_event *fde, uint16_t flags)
{
+ if (!fde) return;
fde->event_ctx->ops->set_fd_flags(fde, flags);
}
/*
do a single event loop using the events defined in ev
*/
-int event_loop_once(struct event_context *ev)
+_PUBLIC_ int event_loop_once(struct event_context *ev)
{
return ev->ops->loop_once(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
+
+ This should be used in preference to event_context_init() in places
+ where you would prefer to use the existing event context if possible
+ (which is most situations)
+*/
+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;
+}