diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-01-06 20:55:38 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-01-08 13:03:02 +1100 |
commit | dcbba583d9a7acbbd0086889f3be722121754eae (patch) | |
tree | d37efa20436e03b08818c79918aa78becf36a21a | |
parent | f25409195737e8e9c29495526f6d2f6c58bda037 (diff) | |
download | samba-dcbba583d9a7acbbd0086889f3be722121754eae.tar.gz samba-dcbba583d9a7acbbd0086889f3be722121754eae.tar.bz2 samba-dcbba583d9a7acbbd0086889f3be722121754eae.zip |
s4-event: added s4_event_context_set_default()
we're still not weaned off event_context_find()
-rw-r--r-- | source4/lib/events/events.h | 1 | ||||
-rw-r--r-- | source4/lib/events/tevent_s4.c | 15 | ||||
-rw-r--r-- | source4/smbd/server.c | 3 |
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; |