From 0f13243f5edc1332fb5842dbfc05a498ba01d406 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 12 May 2017 02:21:28 +0200 Subject: [PATCH] ldb: Add ldb_set_require_private_event_context() This will allow us to force use of the global event context for use when Samba must make an IRPC call from within the ldb stack, to another part of the same process Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher Reviewed-by: Garming Sam --- lib/ldb/ABI/ldb-1.1.29.sigs | 1 + lib/ldb/common/ldb.c | 4 ++++ lib/ldb/include/ldb_module.h | 2 ++ lib/ldb/include/ldb_private.h | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/lib/ldb/ABI/ldb-1.1.29.sigs b/lib/ldb/ABI/ldb-1.1.29.sigs index 70688cf6ae2..5e84b0ac074 100644 --- a/lib/ldb/ABI/ldb-1.1.29.sigs +++ b/lib/ldb/ABI/ldb-1.1.29.sigs @@ -239,6 +239,7 @@ ldb_set_event_context: void (struct ldb_context *, struct tevent_context *) ldb_set_flags: void (struct ldb_context *, unsigned int) ldb_set_modules_dir: void (struct ldb_context *, const char *) ldb_set_opaque: int (struct ldb_context *, const char *, void *) +ldb_set_require_private_event_context: void (struct ldb_context *) ldb_set_timeout: int (struct ldb_context *, struct ldb_request *, int) ldb_set_timeout_from_prev_req: int (struct ldb_context *, struct ldb_request *, struct ldb_request *) ldb_set_utf8_default: void (struct ldb_context *) diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c index 5aec1f43f85..628e661c91b 100644 --- a/lib/ldb/common/ldb.c +++ b/lib/ldb/common/ldb.c @@ -758,6 +758,10 @@ struct tevent_context *ldb_handle_get_event_context(struct ldb_handle *handle) return ldb_get_event_context(handle->ldb); } +void ldb_set_require_private_event_context(struct ldb_context *ldb) +{ + ldb->require_private_event_context = true; +} /* trace a ldb request diff --git a/lib/ldb/include/ldb_module.h b/lib/ldb/include/ldb_module.h index fc8575c22d8..54fa98984a9 100644 --- a/lib/ldb/include/ldb_module.h +++ b/lib/ldb/include/ldb_module.h @@ -199,6 +199,8 @@ typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], struct ldb_module **module); +void ldb_set_require_private_event_context(struct ldb_context *ldb); + struct ldb_backend_ops { const char *name; ldb_connect_fn connect_fn; diff --git a/lib/ldb/include/ldb_private.h b/lib/ldb/include/ldb_private.h index 6e82b3bf478..8b233d3aa95 100644 --- a/lib/ldb/include/ldb_private.h +++ b/lib/ldb/include/ldb_private.h @@ -140,6 +140,13 @@ struct ldb_context { struct tevent_context *ev_ctx; + /* + * If the backend holds locks, we must not use a global event + * context, so this flag will be set and ldb_handle_new() will + * build a new event context + */ + bool require_private_event_context; + bool prepare_commit_done; char *partial_debug; -- 2.47.2