diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/events/events.h | 1 | ||||
-rw-r--r-- | source4/lib/events/tevent_s4.c | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/source4/lib/events/events.h b/source4/lib/events/events.h index 1b2dbde32b..5fdb96794e 100644 --- a/source4/lib/events/events.h +++ b/source4/lib/events/events.h @@ -4,4 +4,5 @@ #include <../lib/tevent/tevent.h> struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx); struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx) _DEPRECATED_; +void s4_event_context_set_default(struct tevent_context *ev); #endif /* __LIB_EVENTS_H__ */ diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c index 1898269c2c..838f20debe 100644 --- a/source4/lib/events/tevent_s4.c +++ b/source4/lib/events/tevent_s4.c @@ -71,6 +71,16 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx) return ev; } +static struct tevent_context *default_tevent_context; + +/* set a default event context that will be used for + * event_context_find() if a parent event context is not found + */ +void s4_event_context_set_default(struct tevent_context *ev) +{ + default_tevent_context = 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 @@ -83,7 +93,10 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx) struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx) { struct tevent_context *ev = talloc_find_parent_bytype(mem_ctx, struct tevent_context); - if (ev == NULL) { + if (ev == NULL) { + ev = default_tevent_context; + } + if (ev == NULL) { ev = tevent_context_init(mem_ctx); } return ev; |