summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/events/events.h1
-rw-r--r--source4/lib/events/tevent_s4.c15
-rw-r--r--source4/smbd/server.c3
3 files changed, 18 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;
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index e73cdfd659..99e9c68a87 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -376,6 +376,9 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
should hang off that */
event_ctx = s4_event_context_init(talloc_autofree_context());
+ /* setup this as the default context */
+ s4_event_context_set_default(event_ctx);
+
if (event_ctx == NULL) {
DEBUG(0,("Initializing event context failed\n"));
return 1;