From 4e83011f72ba3df387512755a17760b42a7bf2f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 21 Apr 2008 17:58:23 -0400 Subject: Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. (This used to be commit 3045d391626fba169aa26be52174883e18d323e9) --- source4/lib/events/events.c | 2 ++ source4/lib/ldb/ldb_ildap/ldb_ildap.c | 16 ++++++++++++++-- source4/lib/ldb_wrap.c | 2 +- source4/lib/messaging/messaging.c | 8 ++++---- source4/lib/socket/testsuite.c | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c index 568aadc31e..252af4443d 100644 --- a/source4/lib/events/events.c +++ b/source4/lib/events/events.c @@ -207,6 +207,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char */ struct event_context *event_context_init(TALLOC_CTX *mem_ctx) { + DEBUG(0, ("New event context requested. Parent: [%s:%p]\n", + mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx)); return event_context_init_byname(mem_ctx, NULL); } diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 79958a86eb..6b50b2f5eb 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -737,6 +737,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, struct ildb_private *ildb; NTSTATUS status; struct cli_credentials *creds; + struct event_context *event_ctx; module = talloc(ldb, struct ldb_module); if (!module) { @@ -756,8 +757,19 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, } module->private_data = ildb; ildb->module = module; - ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"), - ldb_get_opaque(ldb, "EventContext")); + + event_ctx = ldb_get_opaque(ldb, "EventContext"); + + /* FIXME: We must make the event context an explicit parameter, but we + * need to build the events library separately first. Hack a new event + * context so that CMD line utilities work until we have libevents for + * standalone builds ready */ + if (event_ctx == NULL) { + event_ctx = event_context_init(NULL); + } + + ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"), + event_ctx); if (!ildb->ldap) { ldb_oom(ldb); goto failed; diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index b71adcbca2..b564976524 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -116,7 +116,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); if (ev == NULL) { - ev = event_context_find(mem_ctx); + return NULL; } if (ldb_set_opaque(ldb, "EventContext", ev)) { diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 29d6e00247..19284461ee 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -544,6 +544,10 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, NTSTATUS status; struct socket_address *path; + if (ev == NULL) { + return NULL; + } + msg = talloc_zero(mem_ctx, struct messaging_context); if (msg == NULL) { return NULL; @@ -556,10 +560,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, return NULL; } - if (ev == NULL) { - ev = event_context_init(msg); - } - /* create the messaging directory if needed */ mkdir(dir, 0700); diff --git a/source4/lib/socket/testsuite.c b/source4/lib/socket/testsuite.c index 813412c7bc..2c25d8f491 100644 --- a/source4/lib/socket/testsuite.c +++ b/source4/lib/socket/testsuite.c @@ -124,7 +124,7 @@ static bool test_tcp(struct torture_context *tctx) DATA_BLOB blob, blob2; size_t sent, nread; TALLOC_CTX *mem_ctx = tctx; - struct event_context *ev = event_context_init(mem_ctx); + struct event_context *ev = tctx->ev; struct interface *ifaces; status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0); -- cgit