ldb: Add ldb_handle_get_event_context()
authorAndrew Bartlett <abartlet@samba.org>
Thu, 4 May 2017 09:39:21 +0000 (11:39 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 31 May 2017 04:34:26 +0000 (06:34 +0200)
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>
lib/ldb/ABI/ldb-1.1.29.sigs
lib/ldb/common/ldb.c
lib/ldb/include/ldb_module.h
lib/ldb/include/ldb_private.h

index 9b865ed89074f399a8d8fd8ce17b981dbe621629..70688cf6ae2c2f4ec06b9478c3a74ed1ae5540e5 100644 (file)
@@ -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 *)
index 01324e3eea0220b0fe1e16291ceb0a582e97afcb..5aec1f43f851aca7a3ed2fd04efa72849a186ab1 100644 (file)
@@ -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
index 75f3fcb2bf8a8dc7274ac64f1a1657744c2c254b..fc8575c22d86ce60dd33d45e2e755fd0d5c2d35f 100644 (file)
@@ -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);
index bd975b81fecb7c5a73400e136f508f2895989dbd..6e82b3bf4787708ca2cd237a2afe656fd5b0aea9 100644 (file)
@@ -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;