ldb: Add ldb_handle_use_global_event_context()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 5 May 2017 06:25:40 +0000 (08:25 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 31 May 2017 04:34:27 +0000 (06:34 +0200)
This will allow the IRPC to be processed in the main event loop of the
server, not the private event context for this request

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

index 5e84b0ac07461996642f5b7b6033068eb10185ed..ef9c53e1a4eba6ea9c929050f3fbc237abe9f5aa 100644 (file)
@@ -96,6 +96,7 @@ 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_handle_use_global_event_context: void (struct ldb_handle *)
 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 *)
 ldb_init: struct ldb_context *(TALLOC_CTX *, struct tevent_context *)
index a033382672406c144d5d4e8d6657feb9b3466838..a3a00028711fe39573cbffea938a87760e130c52 100644 (file)
@@ -814,6 +814,21 @@ struct tevent_context *ldb_handle_get_event_context(struct ldb_handle *handle)
        return ldb_get_event_context(handle->ldb);
 }
 
+/*
+ * This function forces a specific ldb handle to use the global event
+ * context.  This allows a nested event loop to operate, so any open
+ * transaction also needs to be aborted.
+ *
+ * Any events on this event context will be lost
+ *
+ * This is used in Samba when sending an IRPC to another part of the
+ * same process instead of making a local DB modification.
+ */
+void ldb_handle_use_global_event_context(struct ldb_handle *handle)
+{
+       TALLOC_FREE(handle->event_context);
+}
+
 void ldb_set_require_private_event_context(struct ldb_context *ldb)
 {
        ldb->require_private_event_context = true;
index 54fa98984a934c11345d3dd9d1880944a1eb9e0b..91887de2efc27e6328a119535617b111046bb0ba 100644 (file)
@@ -447,4 +447,16 @@ int ldb_unpack_data_only_attr_list_flags(struct ldb_context *ldb,
 #define LDB_UNPACK_DATA_FLAG_NO_DN           0x0002
 #define LDB_UNPACK_DATA_FLAG_NO_VALUES_ALLOC 0x0004
 
+/*
+ * This function forces a specific ldb handle to use the global event
+ * context.  This allows a nested event loop to operate, so any open
+ * transaction also needs to be aborted.
+ *
+ * Any events on this event context will be lost
+ *
+ * This is used in Samba when sending an IRPC to another part of the
+ * same process instead of making a local DB modification.
+ */
+void ldb_handle_use_global_event_context(struct ldb_handle *handle);
+
 #endif