From 509814bd037a3c73fea4ab92b531c25964f34dfa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 3 Mar 2006 20:01:19 +0000 Subject: r13823: make async_wait part of the modules ops (This used to be commit b4202cf030d5f154f0f94f5f501ecd648ba5c48f) --- source4/lib/ldb/common/ldb.c | 9 +++++---- source4/lib/ldb/common/ldb_modules.c | 8 +++++++- source4/lib/ldb/include/ldb_private.h | 3 +-- source4/lib/ldb/ldb_ildap/ldb_ildap.c | 5 ++--- source4/lib/ldb/ldb_ldap/ldb_ldap.c | 5 ++--- source4/lib/ldb/ldb_tdb/ldb_search.c | 2 +- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 7 +++---- 7 files changed, 21 insertions(+), 18 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 28bed0b0ea..9d8783324c 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -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); } /* diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index f1b4783fca..17c5231e54 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -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); +} diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d4cba9797c..ba6823559f 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -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 *); }; diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index a3af7dedba..869aec01cd 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -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: diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 540dfc690b..031fd847e3 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -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: diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 46f560f817..5ffd45aa3b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -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")); diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 04766c53a1..da9596199a 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -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 = <db_ops; ldb->sequence_number = ltdb_sequence_number; - ldb->async_wait = <db_async_wait; - return 0; } -- cgit