diff options
author | Andrew Bartlett <abartlet@samba.org> | 2017-05-04 11:39:21 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-05-31 06:34:26 +0200 |
commit | a83df55693bf04fb65d776af2591c8c82f211d6c (patch) | |
tree | 518879262d8fbad8a8fa146710024110f781ec29 | |
parent | 1ba6b9aae88f369c58f250aa53223d98aad8564c (diff) | |
download | samba-a83df55693bf04fb65d776af2591c8c82f211d6c.tar.gz |
ldb: Add ldb_handle_get_event_context()
This will allow us to obtain a private event context for use while we hold
locks in ldb_tdb, that is not shared with the global state of the application.
This will ensure we do not perform other operations while we hold the lock
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
-rw-r--r-- | lib/ldb/ABI/ldb-1.1.29.sigs | 1 | ||||
-rw-r--r-- | lib/ldb/common/ldb.c | 13 | ||||
-rw-r--r-- | lib/ldb/include/ldb_module.h | 7 | ||||
-rw-r--r-- | lib/ldb/include/ldb_private.h | 3 |
4 files changed, 24 insertions, 0 deletions
diff --git a/lib/ldb/ABI/ldb-1.1.29.sigs b/lib/ldb/ABI/ldb-1.1.29.sigs index 9b865ed8907..70688cf6ae2 100644 --- a/lib/ldb/ABI/ldb-1.1.29.sigs +++ b/lib/ldb/ABI/ldb-1.1.29.sigs @@ -94,6 +94,7 @@ ldb_get_opaque: void *(struct ldb_context *, const char *) ldb_get_root_basedn: struct ldb_dn *(struct ldb_context *) ldb_get_schema_basedn: struct ldb_dn *(struct ldb_context *) ldb_global_init: int (void) +ldb_handle_get_event_context: struct tevent_context *(struct ldb_handle *) ldb_handle_new: struct ldb_handle *(TALLOC_CTX *, struct ldb_context *) ldb_handler_copy: int (struct ldb_context *, void *, const struct ldb_val *, struct ldb_val *) ldb_handler_fold: int (struct ldb_context *, void *, const struct ldb_val *, struct ldb_val *) diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c index 01324e3eea0..5aec1f43f85 100644 --- a/lib/ldb/common/ldb.c +++ b/lib/ldb/common/ldb.c @@ -745,6 +745,19 @@ int ldb_request_get_status(struct ldb_request *req) return req->handle->status; } +/* + * This function obtains the private event context for the handle, + * which may have been created to avoid nested event loops during + * ldb_tdb with the locks held + */ +struct tevent_context *ldb_handle_get_event_context(struct ldb_handle *handle) +{ + if (handle->event_context != NULL) { + return handle->event_context; + } + return ldb_get_event_context(handle->ldb); +} + /* trace a ldb request diff --git a/lib/ldb/include/ldb_module.h b/lib/ldb/include/ldb_module.h index 75f3fcb2bf8..fc8575c22d8 100644 --- a/lib/ldb/include/ldb_module.h +++ b/lib/ldb/include/ldb_module.h @@ -210,6 +210,13 @@ int ldb_register_backend(const char *url_prefix, ldb_connect_fn, bool); struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); +/* + * This function obtains the private event context for the handle, + * which may have been created to avoid nested event loops during + * ldb_tdb with the locks held + */ +struct tevent_context *ldb_handle_get_event_context(struct ldb_handle *handle); + int ldb_module_send_entry(struct ldb_request *req, struct ldb_message *msg, struct ldb_control **ctrls); diff --git a/lib/ldb/include/ldb_private.h b/lib/ldb/include/ldb_private.h index bd975b81fec..6e82b3bf478 100644 --- a/lib/ldb/include/ldb_private.h +++ b/lib/ldb/include/ldb_private.h @@ -62,6 +62,9 @@ struct ldb_handle { uint32_t custom_flags; unsigned nesting; + /* Private event context (if not NULL) */ + struct tevent_context *event_context; + /* used for debugging */ struct ldb_request *parent; const char *location; |