r13823: make async_wait part of the modules ops
authorSimo Sorce <idra@samba.org>
Fri, 3 Mar 2006 20:01:19 +0000 (20:01 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:52:13 +0000 (13:52 -0500)
(This used to be commit b4202cf030d5f154f0f94f5f501ecd648ba5c48f)

source4/dsdb/samdb/ldb_modules/rootdse.c
source4/lib/ldb/common/ldb.c
source4/lib/ldb/common/ldb_modules.c
source4/lib/ldb/include/ldb_private.h
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/lib/ldb/ldb_ldap/ldb_ldap.c
source4/lib/ldb/ldb_tdb/ldb_search.c
source4/lib/ldb/ldb_tdb/ldb_tdb.c

index 69b1648040ab098821380b06a388b394cfb23065..14d6a243c411d13e351c009646152ea705e03a81 100644 (file)
@@ -217,7 +217,7 @@ static int rootdse_init(struct ldb_module *module)
 
 static const struct ldb_module_ops rootdse_ops = {
        .name                   = "rootdse",
-       .init_context   = rootdse_init,
+       .init_context           = rootdse_init,
        .request                = rootdse_request
 };
 
index 28bed0b0ea6ee06ac7e635e07c67f6cdc7f31a9a..9d8783324ca5209404465a1f5d4483e0099f9ef3 100644 (file)
@@ -125,7 +125,7 @@ void ldb_reset_err_string(struct ldb_context *ldb)
 #define FIRST_OP(ldb, op) do { \
        module = ldb->modules; \
        while (module && module->ops->op == NULL) module = module->next; \
-       if (module == NULL) return -1; \
+       if (module == NULL) return LDB_ERR_OPERATIONS_ERROR; \
 } while (0)
 
 /*
@@ -208,10 +208,11 @@ int ldb_transaction_cancel(struct ldb_context *ldb)
 
 int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type)
 {
-       if (ldb->async_wait != NULL)
-               return ldb->async_wait(handle, type);
+       struct ldb_module *module;
+
+       FIRST_OP(ldb, async_wait);
 
-       return LDB_ERR_OPERATIONS_ERROR;
+       return module->ops->async_wait(module, handle, type);
 }
 
 /*
index f1b4783fcaec105055ff676651f43c6cf02731e2..17c5231e548149a60f74cca4dc78660e040f062d 100644 (file)
@@ -278,7 +278,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
 #define FIND_OP(module, op) do { \
        module = module->next; \
        while (module && module->ops->op == NULL) module = module->next; \
-       if (module == NULL) return LDB_ERR_OTHER; \
+       if (module == NULL) return LDB_ERR_OPERATIONS_ERROR; \
 } while (0)
 
 
@@ -324,3 +324,9 @@ int ldb_next_del_trans(struct ldb_module *module)
        FIND_OP(module, del_transaction);
        return module->ops->del_transaction(module);
 }
+
+int ldb_next_async_wait(struct ldb_module *module, struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+{
+       FIND_OP(module, async_wait);
+       return module->ops->async_wait(module, handle, type);
+}
index d4cba9797c4671eeeaa024106cd2065fa9f374c1..ba6823559f112c9699e8451ca1223206edad8dac 100644 (file)
@@ -61,6 +61,7 @@ struct ldb_module_ops {
        int (*start_transaction)(struct ldb_module *);
        int (*end_transaction)(struct ldb_module *);
        int (*del_transaction)(struct ldb_module *);
+       int (*async_wait)(struct ldb_module *, struct ldb_async_handle *, enum ldb_async_wait_type);
 };
 
 
@@ -106,8 +107,6 @@ struct ldb_context {
 
        int transaction_active;
 
-       int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type);
-
        /* a backend supplied highestCommittedUSN function */
        uint64_t (*sequence_number)(struct ldb_context *);
 };
index a3af7dedbae0ddd56142237ec2d7922d37b89a57..869aec01cdb94ab361fca7be2946b3d18120245b 100644 (file)
@@ -913,7 +913,7 @@ static int ildb_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
-static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int ildb_async_wait(struct ldb_module *module, struct ldb_async_handle *handle, enum ldb_async_wait_type type)
 {
        struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
 
@@ -977,6 +977,7 @@ static const struct ldb_module_ops ildb_ops = {
        .start_transaction = ildb_start_trans,
        .end_transaction   = ildb_end_trans,
        .del_transaction   = ildb_del_trans,
+       .async_wait        = ildb_async_wait,
        .init_context      = ildb_init
 };
 
@@ -1051,8 +1052,6 @@ int ildb_connect(struct ldb_context *ldb, const char *url,
                }
        }
 
-       ldb->async_wait = &ildb_async_wait;
-
        return 0;
 
 failed:
index 540dfc690b0a331071e3843a031d2362dc4b686d..031fd847e36a963618b611b58c5b3aae3f1433d3 100644 (file)
@@ -860,7 +860,7 @@ error:
        return handle->status;
 }
 
-static int lldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int lldb_async_wait(struct ldb_module *module, struct ldb_async_handle *handle, enum ldb_async_wait_type type)
 {
        struct lldb_async_context *ac = talloc_get_type(handle->private_data, struct lldb_async_context);
        struct lldb_private *lldb = talloc_get_type(ac->module->private_data, struct lldb_private);
@@ -1027,6 +1027,7 @@ static const struct ldb_module_ops lldb_ops = {
        .start_transaction = lldb_start_trans,
        .end_transaction   = lldb_end_trans,
        .del_transaction   = lldb_del_trans,
+       .async_wait        = lldb_async_wait
 };
 
 
@@ -1084,8 +1085,6 @@ int lldb_connect(struct ldb_context *ldb,
        ldb->modules->private_data = lldb;
        ldb->modules->ops = &lldb_ops;
 
-       ldb->async_wait = &lldb_async_wait;
-
        return 0;
 
 failed:
index 46f560f817561d33886c2b71a1d4a40537bfb47a..5ffd45aa3b71b347fd9841a767b9cf1be990f145 100644 (file)
@@ -475,7 +475,7 @@ static int ltdb_search_full(struct ldb_async_handle *handle)
 
 static int ltdb_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
 {
-       struct ldb_result *res;
+       struct ldb_result *res = NULL;
        
        if (!context) {
                ldb_set_errstring(ldb, talloc_strdup(ldb, "NULL Context in callback"));
index 04766c53a133aa14d43b8a615236c2f0bc075792..da9596199aaa37334ba78ade20c595d87be411a0 100644 (file)
@@ -917,7 +917,7 @@ static int ltdb_del_trans(struct ldb_module *module)
        return LDB_SUCCESS;
 }
 
-static int ltdb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int ltdb_async_wait(struct ldb_module *module, struct ldb_async_handle *handle, enum ldb_async_wait_type type)
 {
        return handle->status;
 }
@@ -1038,7 +1038,8 @@ static const struct ldb_module_ops ltdb_ops = {
        .request           = ltdb_request,
        .start_transaction = ltdb_start_trans,
        .end_transaction   = ltdb_end_trans,
-       .del_transaction   = ltdb_del_trans
+       .del_transaction   = ltdb_del_trans,
+       .async_wait        = ltdb_async_wait
 };
 
 
@@ -1104,7 +1105,5 @@ int ltdb_connect(struct ldb_context *ldb, const char *url,
        ldb->modules->ops = &ltdb_ops;
        ldb->sequence_number = ltdb_sequence_number;
 
-       ldb->async_wait = &ltdb_async_wait;
-
        return 0;
 }