From c93817b36d3ff7f44cb7b3e1d1a29e37ec12affe Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 16:56:33 +0000 Subject: r17185: Oh, I wanted to do this for sooo long time. Finally acknowledge that ldb is inherently async and does not have a dual personality anymore Rename all ldb_async_XXX functions to ldb_XXX except for ldb_async_result, it is now ldb_reply to reflect the real function of this structure. Simo. (This used to be commit 25fc7354049d62efeba17681ef1cdd326bc3f2ef) --- source4/lib/ldb/common/ldb.c | 10 +-- source4/lib/ldb/include/ldb.h | 16 ++--- source4/lib/ldb/include/ldb_private.h | 2 +- source4/lib/ldb/ldb_ildap/ldb_ildap.c | 38 +++++------ source4/lib/ldb/ldb_ldap/ldb_ldap.c | 54 +++++++-------- source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 90 ++++++++++++------------- source4/lib/ldb/ldb_tdb/ldb_index.c | 12 ++-- source4/lib/ldb/ldb_tdb/ldb_search.c | 16 ++--- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 32 ++++----- source4/lib/ldb/ldb_tdb/ldb_tdb.h | 10 +-- source4/lib/ldb/modules/asq.c | 76 ++++++++++----------- source4/lib/ldb/modules/objectclass.c | 62 ++++++++--------- source4/lib/ldb/modules/operational.c | 4 +- source4/lib/ldb/modules/paged_results.c | 56 ++++++++-------- source4/lib/ldb/modules/rdn_name.c | 38 +++++------ source4/lib/ldb/modules/sort.c | 58 ++++++++-------- source4/lib/ldb/tools/ldbsearch.c | 108 +++++++++++++++--------------- 17 files changed, 341 insertions(+), 341 deletions(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 8e814778d1..a962aa4322 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -335,7 +335,7 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque ret = ldb_request(ldb, req); if (ret == LDB_SUCCESS) { - ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL); + ret = ldb_wait(req->async.handle, LDB_WAIT_ALL); } if (ret == LDB_SUCCESS) { @@ -353,13 +353,13 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque return ret; } -int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type) { if (!handle) { return LDB_SUCCESS; } - return handle->module->ops->async_wait(handle, type); + return handle->module->ops->wait(handle, type); } /* set the specified timeout or, if timeout is 0 set the default timeout */ @@ -454,7 +454,7 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req) Use talloc_free to free the ldb_message returned in 'res', if successful */ -static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { struct ldb_result *res; int n; @@ -563,7 +563,7 @@ int ldb_search(struct ldb_context *ldb, ret = ldb_request(ldb, req); if (ret == LDB_SUCCESS) { - ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL); + ret = ldb_wait(req->async.handle, LDB_WAIT_ALL); } if (ret != LDB_SUCCESS) { diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2f0464b953..885842ff9c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -578,12 +578,12 @@ enum ldb_reply_type { LDB_REPLY_DONE }; -enum ldb_async_wait_type { +enum ldb_wait_type { LDB_WAIT_ALL, LDB_WAIT_NONE }; -enum ldb_async_state { +enum ldb_state { LDB_ASYNC_INIT, LDB_ASYNC_PENDING, LDB_ASYNC_DONE @@ -596,16 +596,16 @@ struct ldb_result { struct ldb_control **controls; }; -struct ldb_async_result { +struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; char *referral; struct ldb_control **controls; }; -struct ldb_async_handle { +struct ldb_handle { int status; - enum ldb_async_state state; + enum ldb_state state; void *private_data; struct ldb_module *module; }; @@ -666,17 +666,17 @@ struct ldb_request { struct { void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); int timeout; time_t starttime; - struct ldb_async_handle *handle; + struct ldb_handle *handle; } async; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 2f2df1a970..1360602000 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -66,7 +66,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_async_handle *, enum ldb_async_wait_type); + int (*wait)(struct ldb_handle *, enum ldb_wait_type); int (*sequence_number)(struct ldb_module *, struct ldb_request *); }; diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 9251451549..3410d68c5e 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -56,11 +56,11 @@ struct ildb_private { struct ldb_context *ldb; }; -struct ildb_async_context { +struct ildb_context { struct ldb_module *module; struct ldap_request *req; void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; /* @@ -136,8 +136,8 @@ static int ildb_map_error(struct ildb_private *ildb, NTSTATUS status) static void ildb_request_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *private_data) { - struct ldb_async_handle *handle = talloc_get_type(private_data, struct ldb_async_handle); - struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context); + struct ldb_handle *handle = talloc_get_type(private_data, struct ldb_handle); + struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context); if (ac->req->state == LDAP_REQUEST_PENDING) { DLIST_REMOVE(ac->req->conn->pending, ac->req); @@ -150,8 +150,8 @@ static void ildb_request_timeout(struct event_context *ev, struct timed_event *t static void ildb_callback(struct ldap_request *req) { - struct ldb_async_handle *handle = talloc_get_type(req->async.private_data, struct ldb_async_handle); - struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context); + struct ldb_handle *handle = talloc_get_type(req->async.private_data, struct ldb_handle); + struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context); struct ildb_private *ildb = talloc_get_type(ac->module->private_data, struct ildb_private); NTSTATUS status; int i; @@ -230,11 +230,11 @@ static void ildb_callback(struct ldap_request *req) /* loop over all messages */ for (i = 0; i < req->num_replies; i++) { struct ldap_SearchResEntry *search; - struct ldb_async_result *ares = NULL; + struct ldb_reply *ares = NULL; struct ldap_message *msg; int ret; - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { handle->status = LDB_ERR_OPERATIONS_ERROR; return; @@ -325,16 +325,16 @@ static void ildb_callback(struct ldap_request *req) static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), int timeout, - struct ldb_async_handle **handle) + struct ldb_handle **handle) { struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); - struct ildb_async_context *ildb_ac; - struct ldb_async_handle *h; + struct ildb_context *ildb_ac; + struct ldb_handle *h; struct ldap_request *req; - h = talloc_zero(ildb->ldap, struct ldb_async_handle); + h = talloc_zero(ildb->ldap, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return LDB_ERR_OPERATIONS_ERROR; @@ -342,7 +342,7 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg h->module = module; - ildb_ac = talloc(h, struct ildb_async_context); + ildb_ac = talloc(h, struct ildb_context); if (ildb_ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -665,9 +665,9 @@ static int ildb_request(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } -static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int ildb_wait(struct ldb_handle *handle, enum ldb_wait_type type) { - struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context); + struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context); if (handle->state == LDB_ASYNC_DONE) { return handle->status; @@ -699,7 +699,7 @@ static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_ return handle->status; } -static int ildb_rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int ildb_rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { struct ildb_private *ildb; @@ -767,7 +767,7 @@ static int ildb_init(struct ldb_module *module) return ret; } - ret = ildb_async_wait(req->async.handle, LDB_WAIT_ALL); + ret = ildb_wait(req->async.handle, LDB_WAIT_ALL); talloc_free(req); return ret; @@ -784,7 +784,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, + .wait = ildb_wait, .init_context = ildb_init }; diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 3df137efaf..f6d24411db 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -49,13 +49,13 @@ struct lldb_private { LDAP *ldap; }; -struct lldb_async_context { +struct lldb_context { struct ldb_module *module; int msgid; int timeout; time_t starttime; void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; static int lldb_ldap_to_ldb(int err) { @@ -63,15 +63,15 @@ static int lldb_ldap_to_ldb(int err) { return err; } -static struct ldb_async_handle *init_handle(struct lldb_private *lldb, struct ldb_module *module, +static struct ldb_handle *init_handle(struct lldb_private *lldb, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), int timeout, time_t starttime) { - struct lldb_async_context *ac; - struct ldb_async_handle *h; + struct lldb_context *ac; + struct ldb_handle *h; - h = talloc_zero(lldb, struct ldb_async_handle); + h = talloc_zero(lldb, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -79,7 +79,7 @@ static struct ldb_async_handle *init_handle(struct lldb_private *lldb, struct ld h->module = module; - ac = talloc(h, struct lldb_async_context); + ac = talloc(h, struct lldb_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -229,7 +229,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, static int lldb_search(struct ldb_module *module, struct ldb_request *req) { struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_async_context *lldb_ac; + struct lldb_context *lldb_ac; struct timeval tv; int ldap_scope; char *search_base; @@ -255,7 +255,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context); + lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context); search_base = ldb_dn_linearize(lldb_ac, req->op.search.base); if (req->op.search.base == NULL) { @@ -308,7 +308,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req) static int lldb_add(struct ldb_module *module, struct ldb_request *req) { struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_async_context *lldb_ac; + struct lldb_context *lldb_ac; LDAPMod **mods; char *dn; int ret; @@ -323,7 +323,7 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context); + lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context); mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0); if (mods == NULL) { @@ -353,7 +353,7 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req) static int lldb_modify(struct ldb_module *module, struct ldb_request *req) { struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_async_context *lldb_ac; + struct lldb_context *lldb_ac; LDAPMod **mods; char *dn; int ret; @@ -368,7 +368,7 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context); + lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context); mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1); if (mods == NULL) { @@ -398,7 +398,7 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req) static int lldb_delete(struct ldb_module *module, struct ldb_request *req) { struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_async_context *lldb_ac; + struct lldb_context *lldb_ac; char *dnstr; int ret; @@ -412,7 +412,7 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context); + lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context); dnstr = ldb_dn_linearize(lldb_ac, req->op.del.dn); @@ -434,7 +434,7 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req) static int lldb_rename(struct ldb_module *module, struct ldb_request *req) { struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_async_context *lldb_ac; + struct lldb_context *lldb_ac; char *old_dn; char *newrdn; char *parentdn; @@ -450,7 +450,7 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context); + lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context); old_dn = ldb_dn_linearize(lldb_ac, req->op.rename.olddn); if (old_dn == NULL) { @@ -480,11 +480,11 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req) return lldb_ldap_to_ldb(ret); } -static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *result) +static int lldb_parse_result(struct ldb_handle *handle, LDAPMessage *result) { - struct lldb_async_context *ac = talloc_get_type(handle->private_data, struct lldb_async_context); + struct lldb_context *ac = talloc_get_type(handle->private_data, struct lldb_context); struct lldb_private *lldb = talloc_get_type(ac->module->private_data, struct lldb_private); - struct ldb_async_result *ares = NULL; + struct ldb_reply *ares = NULL; LDAPMessage *msg; int type; char *matcheddnp = NULL; @@ -503,7 +503,7 @@ static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *resul BerElement *berptr = NULL; char *attr, *dn; - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; goto error; @@ -566,7 +566,7 @@ static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *resul goto error; } - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; goto error; @@ -586,7 +586,7 @@ static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *resul goto error; } - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; goto error; @@ -642,9 +642,9 @@ error: return ret; } -static int lldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int lldb_wait(struct ldb_handle *handle, enum ldb_wait_type type) { - struct lldb_async_context *ac = talloc_get_type(handle->private_data, struct lldb_async_context); + struct lldb_context *ac = talloc_get_type(handle->private_data, struct lldb_context); struct lldb_private *lldb = talloc_get_type(handle->module->private_data, struct lldb_private); struct timeval timeout; LDAPMessage *result; @@ -758,7 +758,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 + .wait = lldb_wait }; diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index c9b453587e..c2ac9f47f4 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -44,27 +44,27 @@ struct lsqlite3_private { sqlite3 *sqlite; }; -struct lsql_async_context { +struct lsql_context { struct ldb_module *module; /* search stuff */ long long current_eid; const char * const * attrs; - struct ldb_async_result *ares; + struct ldb_reply *ares; /* async stuff */ void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; -static struct ldb_async_handle *init_handle(struct lsqlite3_private *lsqlite3, struct ldb_module *module, +static struct ldb_handle *init_handle(struct lsqlite3_private *lsqlite3, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *)) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) { - struct lsql_async_context *ac; - struct ldb_async_handle *h; + struct lsql_context *ac; + struct ldb_handle *h; - h = talloc_zero(lsqlite3, struct ldb_async_handle); + h = talloc_zero(lsqlite3, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -72,7 +72,7 @@ static struct ldb_async_handle *init_handle(struct lsqlite3_private *lsqlite3, s h->module = module; - ac = talloc(h, struct lsql_async_context); + ac = talloc(h, struct lsql_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -711,8 +711,8 @@ static int lsqlite3_eid_callback(void *result, int col_num, char **cols, char ** */ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char **names) { - struct ldb_async_handle *handle = talloc_get_type(result, struct ldb_async_handle); - struct lsql_async_context *ac = talloc_get_type(handle->private_data, struct lsql_async_context); + struct ldb_handle *handle = talloc_get_type(result, struct ldb_handle); + struct lsql_context *ac = talloc_get_type(handle->private_data, struct lsql_context); struct ldb_message *msg; long long eid; int i; @@ -738,7 +738,7 @@ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char } /* start over */ - ac->ares = talloc_zero(ac, struct ldb_async_result); + ac->ares = talloc_zero(ac, struct ldb_reply); if (!ac->ares) return SQLITE_ABORT; @@ -842,7 +842,7 @@ done: * Interface functions referenced by lsqlite3_ops */ -static int lsql_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int lsql_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { struct ldb_result *res = NULL; @@ -891,11 +891,11 @@ int lsql_search_async(struct ldb_module *module, const struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const *attrs, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), - struct ldb_async_handle **handle) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), + struct ldb_handle **handle) { struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_async_context *lsql_ac; + struct lsql_context *lsql_ac; char *norm_basedn; char *sqlfilter; char *errmsg; @@ -908,7 +908,7 @@ int lsql_search_async(struct ldb_module *module, const struct ldb_dn *base, return LDB_ERR_OPERATIONS_ERROR; } - lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context); + lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context); if (base) { norm_basedn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, base)); @@ -1075,7 +1075,7 @@ static int lsql_search_bytree(struct ldb_module * module, const struct ldb_dn* b enum ldb_scope scope, struct ldb_parse_tree * tree, const char * const * attrs, struct ldb_result ** res) { - struct ldb_async_handle *handle; + struct ldb_handle *handle; int ret; *res = talloc_zero(module, struct ldb_result); @@ -1088,7 +1088,7 @@ static int lsql_search_bytree(struct ldb_module * module, const struct ldb_dn* b &handle); if (ret == LDB_SUCCESS) { - ret = ldb_async_wait(handle, LDB_WAIT_ALL); + ret = ldb_wait(handle, LDB_WAIT_ALL); talloc_free(handle); } @@ -1102,11 +1102,11 @@ static int lsql_search_bytree(struct ldb_module * module, const struct ldb_dn* b /* add a record */ static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), - struct ldb_async_handle **handle) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), + struct ldb_handle **handle) { struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_async_context *lsql_ac; + struct lsql_context *lsql_ac; long long eid; char *dn, *ndn; char *errmsg; @@ -1118,7 +1118,7 @@ static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg, if (*handle == NULL) { goto failed; } - lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context); + lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context); (*handle)->state = LDB_ASYNC_DONE; (*handle)->status = LDB_SUCCESS; @@ -1242,7 +1242,7 @@ failed: static int lsql_add(struct ldb_module *module, const struct ldb_message *msg) { - struct ldb_async_handle *handle; + struct ldb_handle *handle; int ret; ret = lsql_add_async(module, msg, NULL, NULL, &handle); @@ -1250,7 +1250,7 @@ static int lsql_add(struct ldb_module *module, const struct ldb_message *msg) if (ret != LDB_SUCCESS) return ret; - ret = ldb_async_wait(handle, LDB_WAIT_ALL); + ret = ldb_wait(handle, LDB_WAIT_ALL); talloc_free(handle); return ret; @@ -1260,11 +1260,11 @@ static int lsql_add(struct ldb_module *module, const struct ldb_message *msg) /* modify a record */ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message *msg, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), - struct ldb_async_handle **handle) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), + struct ldb_handle **handle) { struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_async_context *lsql_ac; + struct lsql_context *lsql_ac; long long eid; char *errmsg; int i; @@ -1274,7 +1274,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message if (*handle == NULL) { goto failed; } - lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context); + lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context); (*handle)->state = LDB_ASYNC_DONE; (*handle)->status = LDB_SUCCESS; @@ -1456,7 +1456,7 @@ failed: static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg) { - struct ldb_async_handle *handle; + struct ldb_handle *handle; int ret; ret = lsql_modify_async(module, msg, NULL, NULL, &handle); @@ -1464,7 +1464,7 @@ static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg) if (ret != LDB_SUCCESS) return ret; - ret = ldb_async_wait(handle, LDB_WAIT_ALL); + ret = ldb_wait(handle, LDB_WAIT_ALL); talloc_free(handle); return ret; @@ -1473,11 +1473,11 @@ static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg) /* delete a record */ static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), - struct ldb_async_handle **handle) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), + struct ldb_handle **handle) { struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_async_context *lsql_ac; + struct lsql_context *lsql_ac; long long eid; char *errmsg; char *query; @@ -1488,7 +1488,7 @@ static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn, if (*handle == NULL) { goto failed; } - lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context); + lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context); (*handle)->state = LDB_ASYNC_DONE; (*handle)->status = LDB_SUCCESS; @@ -1530,7 +1530,7 @@ failed: static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn) { - struct ldb_async_handle *handle; + struct ldb_handle *handle; int ret; /* ignore ltdb specials */ @@ -1543,7 +1543,7 @@ static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn) if (ret != LDB_SUCCESS) return ret; - ret = ldb_async_wait(handle, LDB_WAIT_ALL); + ret = ldb_wait(handle, LDB_WAIT_ALL); talloc_free(handle); return ret; @@ -1552,11 +1552,11 @@ static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn) /* rename a record */ static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), - struct ldb_async_handle **handle) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *), + struct ldb_handle **handle) { struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_async_context *lsql_ac; + struct lsql_context *lsql_ac; char *new_dn, *new_cdn, *old_cdn; char *errmsg; char *query; @@ -1566,7 +1566,7 @@ static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *old if (*handle == NULL) { goto failed; } - lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context); + lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context); (*handle)->state = LDB_ASYNC_DONE; (*handle)->status = LDB_SUCCESS; @@ -1610,7 +1610,7 @@ failed: static int lsql_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn) { - struct ldb_async_handle *handle; + struct ldb_handle *handle; int ret; /* ignore ltdb specials */ @@ -1624,7 +1624,7 @@ static int lsql_rename(struct ldb_module *module, const struct ldb_dn *olddn, co if (ret != LDB_SUCCESS) return ret; - ret = ldb_async_wait(handle, LDB_WAIT_ALL); + ret = ldb_wait(handle, LDB_WAIT_ALL); talloc_free(handle); return ret; @@ -1971,7 +1971,7 @@ static int destructor(struct lsqlite3_private *lsqlite3) return 0; } -static int lsql_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int lsql_wait(struct ldb_handle *handle, enum ldb_wait_type type) { return handle->status; } @@ -2066,7 +2066,7 @@ static const struct ldb_module_ops lsqlite3_ops = { .start_transaction = lsql_start_trans, .end_transaction = lsql_end_trans, .del_transaction = lsql_del_trans, - .async_wait = lsql_async_wait, + .wait = lsql_wait, }; /* diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 3473ed3ac1..7b67db33d3 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -628,17 +628,17 @@ static int ltdb_index_dn(struct ldb_module *module, extracting just the given attributes */ static int ltdb_index_filter(const struct dn_list *dn_list, - struct ldb_async_handle *handle) + struct ldb_handle *handle) { - struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context); - struct ldb_async_result *ares = NULL; + struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); + struct ldb_reply *ares = NULL; unsigned int i; for (i = 0; i < dn_list->count; i++) { struct ldb_dn *dn; int ret; - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { handle->status = LDB_ERR_OPERATIONS_ERROR; handle->state = LDB_ASYNC_DONE; @@ -707,9 +707,9 @@ static int ltdb_index_filter(const struct dn_list *dn_list, returns -1 if an indexed search is not possible, in which case the caller should call ltdb_search_full() */ -int ltdb_search_indexed(struct ldb_async_handle *handle) +int ltdb_search_indexed(struct ldb_handle *handle) { - struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context); + struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private); struct dn_list *dn_list; int ret; diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 529049e36b..62e310ede6 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -378,9 +378,9 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) */ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { - struct ldb_async_handle *handle = talloc_get_type(state, struct ldb_async_handle); - struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context); - struct ldb_async_result *ares = NULL; + struct ldb_handle *handle = talloc_get_type(state, struct ldb_handle); + struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); + struct ldb_reply *ares = NULL; int ret; if (key.dsize < 4 || @@ -388,7 +388,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi return 0; } - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { handle->status = LDB_ERR_OPERATIONS_ERROR; handle->state = LDB_ASYNC_DONE; @@ -454,9 +454,9 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi search the database with a LDAP-like expression. this is the "full search" non-indexed variant */ -static int ltdb_search_full(struct ldb_async_handle *handle) +static int ltdb_search_full(struct ldb_handle *handle) { - struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context); + struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private); int ret; @@ -477,7 +477,7 @@ static int ltdb_search_full(struct ldb_async_handle *handle) int ltdb_search(struct ldb_module *module, struct ldb_request *req) { struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); - struct ltdb_async_context *ltdb_ac; + struct ltdb_context *ltdb_ac; int ret; if ((req->op.search.base == NULL || req->op.search.base->comp_num == 0) && @@ -504,7 +504,7 @@ int ltdb_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context); + ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context); ltdb_ac->tree = req->op.search.tree; ltdb_ac->scope = req->op.search.scope; diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 090151cad9..ababedad15 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -78,14 +78,14 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code) } -struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module, +struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *)) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) { - struct ltdb_async_context *ac; - struct ldb_async_handle *h; + struct ltdb_context *ac; + struct ldb_handle *h; - h = talloc_zero(ltdb, struct ldb_async_handle); + h = talloc_zero(ltdb, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -93,7 +93,7 @@ struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_ h->module = module; - ac = talloc_zero(h, struct ltdb_async_context); + ac = talloc_zero(h, struct ltdb_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -288,7 +288,7 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message static int ltdb_add(struct ldb_module *module, struct ldb_request *req) { struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); - struct ltdb_async_context *ltdb_ac; + struct ltdb_context *ltdb_ac; int tret, ret = LDB_SUCCESS; if (req->controls != NULL) { @@ -302,7 +302,7 @@ static int ltdb_add(struct ldb_module *module, struct ldb_request *req) if (req->async.handle == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context); + ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context); tret = ltdb_add_internal(module, req->op.add.message); if (tret != LDB_SUCCESS) { @@ -390,7 +390,7 @@ static int ltdb_delete_internal(struct ldb_module *module, const struct ldb_dn * static int ltdb_delete(struct ldb_module *module, struct ldb_request *req) { struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); - struct ltdb_async_context *ltdb_ac; + struct ltdb_context *ltdb_ac; int tret, ret = LDB_SUCCESS; if (req->controls != NULL) { @@ -410,7 +410,7 @@ static int ltdb_delete(struct ldb_module *module, struct ldb_request *req) if (req->async.handle == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context); + ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context); tret = ltdb_delete_internal(module, req->op.del.dn); if (tret != LDB_SUCCESS) { @@ -754,7 +754,7 @@ failed: static int ltdb_modify(struct ldb_module *module, struct ldb_request *req) { struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); - struct ltdb_async_context *ltdb_ac; + struct ltdb_context *ltdb_ac; int tret, ret = LDB_SUCCESS; if (req->controls != NULL) { @@ -770,7 +770,7 @@ static int ltdb_modify(struct ldb_module *module, struct ldb_request *req) if (req->async.handle == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context); + ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context); tret = ltdb_check_special_dn(module, req->op.mod.message); if (tret != LDB_SUCCESS) { @@ -803,7 +803,7 @@ done: static int ltdb_rename(struct ldb_module *module, struct ldb_request *req) { struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); - struct ltdb_async_context *ltdb_ac; + struct ltdb_context *ltdb_ac; struct ldb_message *msg; int tret, ret = LDB_SUCCESS; @@ -824,7 +824,7 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req) if (req->async.handle == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context); + ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context); msg = talloc(ltdb_ac, struct ldb_message); if (msg == NULL) { @@ -901,7 +901,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_wait(struct ldb_handle *handle, enum ldb_wait_type type) { return handle->status; } @@ -965,7 +965,7 @@ static const struct ldb_module_ops ltdb_ops = { .start_transaction = ltdb_start_trans, .end_transaction = ltdb_end_trans, .del_transaction = ltdb_del_trans, - .async_wait = ltdb_async_wait, + .wait = ltdb_wait, .sequence_number = ltdb_sequence_number }; diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index 069a07d319..7c6c5dfdb0 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -33,7 +33,7 @@ struct ltdb_private { the async local context holds also internal search state during a full db search */ -struct ltdb_async_context { +struct ltdb_context { struct ldb_module *module; /* search stuff */ @@ -44,7 +44,7 @@ struct ltdb_async_context { /* async stuff */ void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; /* special record types */ @@ -71,7 +71,7 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value); struct ldb_parse_tree; -int ltdb_search_indexed(struct ldb_async_handle *handle); +int ltdb_search_indexed(struct ldb_handle *handle); int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg); int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg); int ltdb_reindex(struct ldb_module *module); @@ -103,9 +103,9 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs); int ltdb_search(struct ldb_module *module, struct ldb_request *req); /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */ -struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module, +struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *)); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)); struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn); int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs); int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn); diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index 2c0baa6827..466286e8cd 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -41,20 +41,20 @@ #define ASQ_CTRL_UNWILLING_TO_PERFORM 53 #define ASQ_CTRL_AFFECTS_MULTIPLE_DSA 71 -struct asq_async_context { +struct asq_context { enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step; struct ldb_module *module; void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); const char * const *req_attrs; char *req_attribute; int asq_ret; struct ldb_request *base_req; - struct ldb_async_result *base_res; + struct ldb_reply *base_res; struct ldb_request **reqs; int num_reqs; @@ -63,14 +63,14 @@ struct asq_async_context { struct ldb_control **controls; }; -static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module, +static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *)) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) { - struct asq_async_context *ac; - struct ldb_async_handle *h; + struct asq_context *ac; + struct ldb_handle *h; - h = talloc_zero(mem_ctx, struct ldb_async_handle); + h = talloc_zero(mem_ctx, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -78,7 +78,7 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo h->module = module; - ac = talloc_zero(h, struct asq_async_context); + ac = talloc_zero(h, struct asq_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -97,19 +97,19 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo return h; } -static int asq_terminate(struct ldb_async_handle *handle) +static int asq_terminate(struct ldb_handle *handle) { - struct asq_async_context *ac; - struct ldb_async_result *ares; + struct asq_context *ac; + struct ldb_reply *ares; struct ldb_asq_control *asq; int i; - ac = talloc_get_type(handle->private_data, struct asq_async_context); + ac = talloc_get_type(handle->private_data, struct asq_context); handle->status = LDB_SUCCESS; handle->state = LDB_ASYNC_DONE; - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (ares == NULL) return LDB_ERR_OPERATIONS_ERROR; @@ -149,16 +149,16 @@ static int asq_terminate(struct ldb_async_handle *handle) return LDB_SUCCESS; } -static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { - struct asq_async_context *ac; + struct asq_context *ac; if (!context || !ares) { ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); goto error; } - ac = talloc_get_type(context, struct asq_async_context); + ac = talloc_get_type(context, struct asq_context); /* we are interested only in the single reply (base search) we receive here */ if (ares->type == LDB_REPLY_ENTRY) { @@ -173,16 +173,16 @@ error: return LDB_ERR_OPERATIONS_ERROR; } -static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { - struct asq_async_context *ac; + struct asq_context *ac; if (!context || !ares) { ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); goto error; } - ac = talloc_get_type(context, struct asq_async_context); + ac = talloc_get_type(context, struct asq_context); /* we are interested only in the single reply (base search) we receive here */ if (ares->type == LDB_REPLY_ENTRY) { @@ -205,8 +205,8 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) { struct ldb_control *control; struct ldb_asq_control *asq_ctrl; - struct asq_async_context *ac; - struct ldb_async_handle *h; + struct asq_context *ac; + struct ldb_handle *h; char **base_attrs; int ret; @@ -234,7 +234,7 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) if (!h) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct asq_async_context); + ac = talloc_get_type(h->private_data, struct asq_context); req->async.handle = h; @@ -281,12 +281,12 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) return LDB_SUCCESS; } -static int asq_async_requests(struct ldb_async_handle *handle) { - struct asq_async_context *ac; +static int asq_requests(struct ldb_handle *handle) { + struct asq_context *ac; struct ldb_message_element *el; int i; - ac = talloc_get_type(handle->private_data, struct asq_async_context); + ac = talloc_get_type(handle->private_data, struct asq_context); /* look up the DNs */ el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute); @@ -329,9 +329,9 @@ static int asq_async_requests(struct ldb_async_handle *handle) { return LDB_SUCCESS; } -static int asq_async_wait_none(struct ldb_async_handle *handle) +static int asq_wait_none(struct ldb_handle *handle) { - struct asq_async_context *ac; + struct asq_context *ac; int ret; if (!handle || !handle->private_data) { @@ -345,12 +345,12 @@ static int asq_async_wait_none(struct ldb_async_handle *handle) handle->state = LDB_ASYNC_PENDING; handle->status = LDB_SUCCESS; - ac = talloc_get_type(handle->private_data, struct asq_async_context); + ac = talloc_get_type(handle->private_data, struct asq_context); switch (ac->step) { case ASQ_SEARCH_BASE: - ret = ldb_async_wait(ac->base_req->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->base_req->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; @@ -365,7 +365,7 @@ static int asq_async_wait_none(struct ldb_async_handle *handle) return LDB_SUCCESS; } - ret = asq_async_requests(handle); + ret = asq_requests(handle); case ASQ_SEARCH_MULTI: @@ -376,7 +376,7 @@ static int asq_async_wait_none(struct ldb_async_handle *handle) } } - ret = ldb_async_wait(ac->reqs[ac->cur_req]->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->reqs[ac->cur_req]->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; @@ -408,12 +408,12 @@ done: return ret; } -static int asq_async_wait_all(struct ldb_async_handle *handle) +static int asq_wait_all(struct ldb_handle *handle) { int ret; while (handle->state != LDB_ASYNC_DONE) { - ret = asq_async_wait_none(handle); + ret = asq_wait_none(handle); if (ret != LDB_SUCCESS) { return ret; } @@ -422,12 +422,12 @@ static int asq_async_wait_all(struct ldb_async_handle *handle) return handle->status; } -static int asq_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int asq_wait(struct ldb_handle *handle, enum ldb_wait_type type) { if (type == LDB_WAIT_ALL) { - return asq_async_wait_all(handle); + return asq_wait_all(handle); } else { - return asq_async_wait_none(handle); + return asq_wait_none(handle); } } @@ -458,7 +458,7 @@ static int asq_init(struct ldb_module *module) static const struct ldb_module_ops asq_ops = { .name = "asq", .search = asq_search, - .async_wait = asq_async_wait, + .wait = asq_wait, .init_context = asq_init }; diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c index eaa3f4472b..03ff58e994 100644 --- a/source4/lib/ldb/modules/objectclass.c +++ b/source4/lib/ldb/modules/objectclass.c @@ -36,7 +36,7 @@ #include "includes.h" #include "ldb/include/includes.h" -struct oc_async_context { +struct oc_context { enum oc_step {OC_DO_REQ, OC_SEARCH_SELF, OC_DO_MOD} step; @@ -46,7 +46,7 @@ struct oc_async_context { struct ldb_request *down_req; struct ldb_request *search_req; - struct ldb_async_result *search_res; + struct ldb_reply *search_res; struct ldb_request *mod_req; }; @@ -56,12 +56,12 @@ struct class_list { const char *objectclass; }; -static struct ldb_async_handle *oc_init_handle(struct ldb_request *req, struct ldb_module *module) +static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_module *module) { - struct oc_async_context *ac; - struct ldb_async_handle *h; + struct oc_context *ac; + struct ldb_handle *h; - h = talloc_zero(req, struct ldb_async_handle); + h = talloc_zero(req, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -69,7 +69,7 @@ static struct ldb_async_handle *oc_init_handle(struct ldb_request *req, struct l h->module = module; - ac = talloc_zero(h, struct oc_async_context); + ac = talloc_zero(h, struct oc_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -389,14 +389,14 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req } { - struct ldb_async_handle *h; - struct oc_async_context *ac; + struct ldb_handle *h; + struct oc_context *ac; h = oc_init_handle(req, module); if (!h) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct oc_async_context); + ac = talloc_get_type(h->private_data, struct oc_context); /* return or own handle to deal with this call */ req->async.handle = h; @@ -420,16 +420,16 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req } } -static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { - struct oc_async_context *ac; + struct oc_context *ac; if (!context || !ares) { ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(context, struct oc_async_context); + ac = talloc_get_type(context, struct oc_context); /* we are interested only in the single reply (base search) we receive here */ if (ares->type == LDB_REPLY_ENTRY) { @@ -447,12 +447,12 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_ return LDB_SUCCESS; } -static int objectclass_search_self(struct ldb_async_handle *h) { +static int objectclass_search_self(struct ldb_handle *h) { - struct oc_async_context *ac; + struct oc_context *ac; static const char * const attrs[] = { "objectClass", NULL }; - ac = talloc_get_type(h->private_data, struct oc_async_context); + ac = talloc_get_type(h->private_data, struct oc_context); /* prepare the search operation */ ac->search_req = talloc_zero(ac, struct ldb_request); @@ -480,16 +480,16 @@ static int objectclass_search_self(struct ldb_async_handle *h) { return ldb_next_request(ac->module, ac->search_req); } -static int objectclass_do_mod(struct ldb_async_handle *h) { +static int objectclass_do_mod(struct ldb_handle *h) { - struct oc_async_context *ac; + struct oc_context *ac; struct ldb_message_element *objectclass_element; struct ldb_message *msg; TALLOC_CTX *mem_ctx; struct class_list *sorted, *current; int ret; - ac = talloc_get_type(h->private_data, struct oc_async_context); + ac = talloc_get_type(h->private_data, struct oc_context); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { @@ -571,8 +571,8 @@ static int objectclass_do_mod(struct ldb_async_handle *h) { return ldb_next_request(ac->module, ac->mod_req); } -static int oc_async_wait(struct ldb_async_handle *handle) { - struct oc_async_context *ac; +static int oc_wait(struct ldb_handle *handle) { + struct oc_context *ac; int ret; if (!handle || !handle->private_data) { @@ -586,11 +586,11 @@ static int oc_async_wait(struct ldb_async_handle *handle) { handle->state = LDB_ASYNC_PENDING; handle->status = LDB_SUCCESS; - ac = talloc_get_type(handle->private_data, struct oc_async_context); + ac = talloc_get_type(handle->private_data, struct oc_context); switch (ac->step) { case OC_DO_REQ: - ret = ldb_async_wait(ac->down_req->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->down_req->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; @@ -609,7 +609,7 @@ static int oc_async_wait(struct ldb_async_handle *handle) { return objectclass_search_self(handle); case OC_SEARCH_SELF: - ret = ldb_async_wait(ac->search_req->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->search_req->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; @@ -628,7 +628,7 @@ static int oc_async_wait(struct ldb_async_handle *handle) { return objectclass_do_mod(handle); case OC_DO_MOD: - ret = ldb_async_wait(ac->mod_req->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->mod_req->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; @@ -657,12 +657,12 @@ done: return ret; } -static int oc_async_wait_all(struct ldb_async_handle *handle) { +static int oc_wait_all(struct ldb_handle *handle) { int ret; while (handle->state != LDB_ASYNC_DONE) { - ret = oc_async_wait(handle); + ret = oc_wait(handle); if (ret != LDB_SUCCESS) { return ret; } @@ -671,12 +671,12 @@ static int oc_async_wait_all(struct ldb_async_handle *handle) { return handle->status; } -static int objectclass_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int objectclass_wait(struct ldb_handle *handle, enum ldb_wait_type type) { if (type == LDB_WAIT_ALL) { - return oc_async_wait_all(handle); + return oc_wait_all(handle); } else { - return oc_async_wait(handle); + return oc_wait(handle); } } @@ -684,7 +684,7 @@ static const struct ldb_module_ops objectclass_ops = { .name = "objectclass", .add = objectclass_add, .modify = objectclass_modify, - .async_wait = objectclass_async_wait + .wait = objectclass_wait }; int ldb_objectclass_init(void) diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index a15a553286..4cadaa27ee 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -230,12 +230,12 @@ struct operational_async_context { struct ldb_module *module; void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); const char * const *attrs; }; -static int operational_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int operational_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { struct operational_async_context *ac; diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index c5a1504fa5..3f2ff66b32 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -37,10 +37,10 @@ #include "ldb/include/includes.h" struct message_store { - /* keep the whole ldb_async_result as an optimization + /* keep the whole ldb_reply as an optimization * instead of freeing and talloc-ing the container * on each result */ - struct ldb_async_result *r; + struct ldb_reply *r; struct message_store *next; }; @@ -122,24 +122,24 @@ static struct results_store *new_store(struct private_data *priv) return new; } -struct paged_async_context { +struct paged_context { struct ldb_module *module; void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); int size; struct results_store *store; }; -static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module, +static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *)) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) { - struct paged_async_context *ac; - struct ldb_async_handle *h; + struct paged_context *ac; + struct ldb_handle *h; - h = talloc_zero(mem_ctx, struct ldb_async_handle); + h = talloc_zero(mem_ctx, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -147,7 +147,7 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo h->module = module; - ac = talloc_zero(h, struct paged_async_context); + ac = talloc_zero(h, struct paged_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -166,16 +166,16 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo return h; } -static int paged_search_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int paged_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { - struct paged_async_context *ac = NULL; + struct paged_context *ac = NULL; if (!context || !ares) { ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); goto error; } - ac = talloc_get_type(context, struct paged_async_context); + ac = talloc_get_type(context, struct paged_context); if (ares->type == LDB_REPLY_ENTRY) { if (ac->store->first == NULL) { @@ -238,8 +238,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) struct private_data *private_data; struct ldb_paged_control *paged_ctrl; struct ldb_control **saved_controls; - struct paged_async_context *ac; - struct ldb_async_handle *h; + struct paged_context *ac; + struct ldb_handle *h; int ret; /* check if there's a paged request control */ @@ -268,7 +268,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) if (!h) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct paged_async_context); + ac = talloc_get_type(h->private_data, struct paged_context); ac->size = paged_ctrl->size; @@ -300,7 +300,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) } ac->store->req->async.context = ac; - ac->store->req->async.callback = paged_search_async_callback; + ac->store->req->async.callback = paged_search_callback; ldb_set_timeout_from_prev_req(module->ldb, req, ac->store->req); ret = ldb_next_request(module, ac->store->req); @@ -339,15 +339,15 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) } -static int paged_results(struct ldb_async_handle *handle) +static int paged_results(struct ldb_handle *handle) { - struct paged_async_context *ac; + struct paged_context *ac; struct ldb_paged_control *paged; - struct ldb_async_result *ares; + struct ldb_reply *ares; struct message_store *msg; int i, num_ctrls, ret; - ac = talloc_get_type(handle->private_data, struct paged_async_context); + ac = talloc_get_type(handle->private_data, struct paged_context); if (ac->store == NULL) return LDB_ERR_OPERATIONS_ERROR; @@ -382,7 +382,7 @@ static int paged_results(struct ldb_async_handle *handle) talloc_free(msg); } - ares = talloc_zero(ac->store, struct ldb_async_result); + ares = talloc_zero(ac->store, struct ldb_reply); if (ares == NULL) { handle->status = LDB_ERR_OPERATIONS_ERROR; return handle->status; @@ -446,9 +446,9 @@ static int paged_results(struct ldb_async_handle *handle) return ret; } -static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int paged_wait(struct ldb_handle *handle, enum ldb_wait_type type) { - struct paged_async_context *ac; + struct paged_context *ac; int ret; if (!handle || !handle->private_data) { @@ -461,7 +461,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait handle->state = LDB_ASYNC_PENDING; - ac = talloc_get_type(handle->private_data, struct paged_async_context); + ac = talloc_get_type(handle->private_data, struct paged_context); if (ac->store->req->async.handle->state == LDB_ASYNC_DONE) { /* if lower level is finished we do not need to call it anymore */ @@ -479,7 +479,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait if (type == LDB_WAIT_ALL) { while (ac->store->req->async.handle->state != LDB_ASYNC_DONE) { - ret = ldb_async_wait(ac->store->req->async.handle, type); + ret = ldb_wait(ac->store->req->async.handle, type); if (ret != LDB_SUCCESS) { handle->state = LDB_ASYNC_DONE; handle->status = ret; @@ -498,7 +498,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait return ret; } - ret = ldb_async_wait(ac->store->req->async.handle, type); + ret = ldb_wait(ac->store->req->async.handle, type); if (ret != LDB_SUCCESS) { handle->state = LDB_ASYNC_DONE; handle->status = ret; @@ -560,7 +560,7 @@ static int paged_request_init(struct ldb_module *module) static const struct ldb_module_ops paged_ops = { .name = "paged_results", .search = paged_search, - .async_wait = paged_async_wait, + .wait = paged_wait, .init_context = paged_request_init }; diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 7aedc260ad..b005b49c55 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -134,7 +134,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) return ret; } -struct rename_async_context { +struct rename_context { enum {RENAME_RENAME, RENAME_MODIFY} step; struct ldb_request *orig_req; @@ -144,8 +144,8 @@ struct rename_async_context { static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) { - struct ldb_async_handle *h; - struct rename_async_context *ac; + struct ldb_handle *h; + struct rename_context *ac; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); @@ -154,14 +154,14 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - h = talloc_zero(req, struct ldb_async_handle); + h = talloc_zero(req, struct ldb_handle); if (h == NULL) { return LDB_ERR_OPERATIONS_ERROR; } h->module = module; - ac = talloc_zero(h, struct rename_async_context); + ac = talloc_zero(h, struct rename_context); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -187,13 +187,13 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, ac->down_req); } -static int rdn_name_rename_do_mod(struct ldb_async_handle *h) { +static int rdn_name_rename_do_mod(struct ldb_handle *h) { - struct rename_async_context *ac; + struct rename_context *ac; struct ldb_dn_component *rdn; struct ldb_message *msg; - ac = talloc_get_type(h->private_data, struct rename_async_context); + ac = talloc_get_type(h->private_data, struct rename_context); rdn = ldb_dn_get_rdn(ac, ac->orig_req->op.rename.newdn); if (rdn == NULL) { @@ -234,9 +234,9 @@ static int rdn_name_rename_do_mod(struct ldb_async_handle *h) { return ldb_request(h->module->ldb, ac->mod_req); } -static int rename_async_wait(struct ldb_async_handle *handle) +static int rename_wait(struct ldb_handle *handle) { - struct rename_async_context *ac; + struct rename_context *ac; int ret; if (!handle || !handle->private_data) { @@ -250,11 +250,11 @@ static int rename_async_wait(struct ldb_async_handle *handle) handle->state = LDB_ASYNC_PENDING; handle->status = LDB_SUCCESS; - ac = talloc_get_type(handle->private_data, struct rename_async_context); + ac = talloc_get_type(handle->private_data, struct rename_context); switch(ac->step) { case RENAME_RENAME: - ret = ldb_async_wait(ac->down_req->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->down_req->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; goto done; @@ -272,7 +272,7 @@ static int rename_async_wait(struct ldb_async_handle *handle) return rdn_name_rename_do_mod(handle); case RENAME_MODIFY: - ret = ldb_async_wait(ac->mod_req->async.handle, LDB_WAIT_NONE); + ret = ldb_wait(ac->mod_req->async.handle, LDB_WAIT_NONE); if (ret != LDB_SUCCESS) { handle->status = ret; goto done; @@ -300,12 +300,12 @@ done: return ret; } -static int rename_async_wait_all(struct ldb_async_handle *handle) { +static int rename_wait_all(struct ldb_handle *handle) { int ret; while (handle->state != LDB_ASYNC_DONE) { - ret = rename_async_wait(handle); + ret = rename_wait(handle); if (ret != LDB_SUCCESS) { return ret; } @@ -314,12 +314,12 @@ static int rename_async_wait_all(struct ldb_async_handle *handle) { return handle->status; } -static int rdn_name_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int rdn_name_wait(struct ldb_handle *handle, enum ldb_wait_type type) { if (type == LDB_WAIT_ALL) { - return rename_async_wait_all(handle); + return rename_wait_all(handle); } else { - return rename_async_wait(handle); + return rename_wait(handle); } } @@ -327,7 +327,7 @@ static const struct ldb_module_ops rdn_name_ops = { .name = "rdn_name", .add = rdn_name_add, .rename = rdn_name_rename, - .async_wait = rdn_name_async_wait + .wait = rdn_name_wait }; diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index d72647be66..261bae7e78 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -43,10 +43,10 @@ struct opaque { int result; }; -struct sort_async_context { +struct sort_context { struct ldb_module *module; void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); char *attributeName; char *orderingRule; @@ -63,14 +63,14 @@ struct sort_async_context { int sort_result; }; -static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module, +static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *)) + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) { - struct sort_async_context *ac; - struct ldb_async_handle *h; + struct sort_context *ac; + struct ldb_handle *h; - h = talloc_zero(mem_ctx, struct ldb_async_handle); + h = talloc_zero(mem_ctx, struct ldb_handle); if (h == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); return NULL; @@ -78,7 +78,7 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo h->module = module; - ac = talloc_zero(h, struct sort_async_context); + ac = talloc_zero(h, struct sort_context); if (ac == NULL) { ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); talloc_free(h); @@ -141,7 +141,7 @@ static int build_response(void *mem_ctx, struct ldb_control ***ctrls, int result static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, void *opaque) { - struct sort_async_context *ac = talloc_get_type(opaque, struct sort_async_context); + struct sort_context *ac = talloc_get_type(opaque, struct sort_context); struct ldb_message_element *el1, *el2; if (ac->sort_result != 0) { @@ -166,16 +166,16 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo return ac->h->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]); } -static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { - struct sort_async_context *ac = NULL; + struct sort_context *ac = NULL; if (!context || !ares) { ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); goto error; } - ac = talloc_get_type(context, struct sort_async_context); + ac = talloc_get_type(context, struct sort_context); if (ares->type == LDB_REPLY_ENTRY) { ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2); @@ -231,8 +231,8 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req struct ldb_control *control; struct ldb_server_sort_control **sort_ctrls; struct ldb_control **saved_controls; - struct sort_async_context *ac; - struct ldb_async_handle *h; + struct sort_context *ac; + struct ldb_handle *h; int ret; /* check if there's a paged request control */ @@ -253,7 +253,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req if (!h) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct sort_async_context); + ac = talloc_get_type(h->private_data, struct sort_context); sort_ctrls = talloc_get_type(control->data, struct ldb_server_sort_control *); if (!sort_ctrls) { @@ -265,9 +265,9 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req if (sort_ctrls[1] != NULL) { if (control->critical) { - struct ldb_async_result *ares; + struct ldb_reply *ares; - ares = talloc_zero(req, struct ldb_async_result); + ares = talloc_zero(req, struct ldb_reply); if (!ares) return LDB_ERR_OPERATIONS_ERROR; @@ -319,13 +319,13 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req return ldb_next_request(module, ac->req); } -static int server_sort_results(struct ldb_async_handle *handle) +static int server_sort_results(struct ldb_handle *handle) { - struct sort_async_context *ac; - struct ldb_async_result *ares; + struct sort_context *ac; + struct ldb_reply *ares; int i, ret; - ac = talloc_get_type(handle->private_data, struct sort_async_context); + ac = talloc_get_type(handle->private_data, struct sort_context); ac->h = ldb_attrib_handler(ac->module->ldb, ac->attributeName); ac->sort_result = 0; @@ -335,7 +335,7 @@ static int server_sort_results(struct ldb_async_handle *handle) ac, (ldb_qsort_cmp_fn_t)sort_compare); for (i = 0; i < ac->num_msgs; i++) { - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { handle->status = LDB_ERR_OPERATIONS_ERROR; return handle->status; @@ -351,7 +351,7 @@ static int server_sort_results(struct ldb_async_handle *handle) } for (i = 0; i < ac->num_refs; i++) { - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { handle->status = LDB_ERR_OPERATIONS_ERROR; return handle->status; @@ -366,7 +366,7 @@ static int server_sort_results(struct ldb_async_handle *handle) } } - ares = talloc_zero(ac, struct ldb_async_result); + ares = talloc_zero(ac, struct ldb_reply); if (!ares) { handle->status = LDB_ERR_OPERATIONS_ERROR; return handle->status; @@ -387,18 +387,18 @@ static int server_sort_results(struct ldb_async_handle *handle) return LDB_SUCCESS; } -static int server_sort_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) +static int server_sort_wait(struct ldb_handle *handle, enum ldb_wait_type type) { - struct sort_async_context *ac; + struct sort_context *ac; int ret; if (!handle || !handle->private_data) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(handle->private_data, struct sort_async_context); + ac = talloc_get_type(handle->private_data, struct sort_context); - ret = ldb_async_wait(ac->req->async.handle, type); + ret = ldb_wait(ac->req->async.handle, type); if (ret != LDB_SUCCESS) { handle->status = ret; @@ -447,7 +447,7 @@ static int server_sort_init(struct ldb_module *module) static const struct ldb_module_ops server_sort_ops = { .name = "server_sort", .search = server_sort_search, - .async_wait = server_sort_async_wait, + .wait = server_sort_wait, .init_context = server_sort_init }; diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 2c8108c9ad..45826f0996 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -58,7 +58,7 @@ static int do_compare_msg(struct ldb_message **el1, return ldb_dn_compare(ldb, (*el1)->dn, (*el2)->dn); } -struct async_context { +struct search_context { struct ldb_control **req_ctrls; int sort; @@ -73,56 +73,56 @@ struct async_context { int status; }; -static int store_message(struct ldb_message *msg, struct async_context *actx) { +static int store_message(struct ldb_message *msg, struct search_context *sctx) { - actx->store = talloc_realloc(actx, actx->store, struct ldb_message *, actx->num_stored + 2); - if (!actx->store) { + sctx->store = talloc_realloc(sctx, sctx->store, struct ldb_message *, sctx->num_stored + 2); + if (!sctx->store) { fprintf(stderr, "talloc_realloc failed while storing messages\n"); return -1; } - actx->store[actx->num_stored] = talloc_steal(actx->store, msg); - if (!actx->store[actx->num_stored]) { + sctx->store[sctx->num_stored] = talloc_steal(sctx->store, msg); + if (!sctx->store[sctx->num_stored]) { fprintf(stderr, "talloc_steal failed while storing messages\n"); return -1; } - actx->num_stored++; - actx->store[actx->num_stored] = NULL; + sctx->num_stored++; + sctx->store[sctx->num_stored] = NULL; return 0; } -static int store_referral(char *referral, struct async_context *actx) { +static int store_referral(char *referral, struct search_context *sctx) { - actx->refs_store = talloc_realloc(actx, actx->refs_store, char *, actx->refs + 2); - if (!actx->refs_store) { + sctx->refs_store = talloc_realloc(sctx, sctx->refs_store, char *, sctx->refs + 2); + if (!sctx->refs_store) { fprintf(stderr, "talloc_realloc failed while storing referrals\n"); return -1; } - actx->refs_store[actx->refs] = talloc_steal(actx->refs_store, referral); - if (!actx->refs_store[actx->refs]) { + sctx->refs_store[sctx->refs] = talloc_steal(sctx->refs_store, referral); + if (!sctx->refs_store[sctx->refs]) { fprintf(stderr, "talloc_steal failed while storing referrals\n"); return -1; } - actx->refs++; - actx->refs_store[actx->refs] = NULL; + sctx->refs++; + sctx->refs_store[sctx->refs] = NULL; return 0; } -static int display_message(struct ldb_context *ldb, struct ldb_message *msg, struct async_context *actx) { +static int display_message(struct ldb_context *ldb, struct ldb_message *msg, struct search_context *sctx) { struct ldb_ldif ldif; - actx->entries++; - printf("# record %d\n", actx->entries); + sctx->entries++; + printf("# record %d\n", sctx->entries); ldif.changetype = LDB_CHANGETYPE_NONE; ldif.msg = msg; - if (actx->sort) { + if (sctx->sort) { /* * Ensure attributes are always returned in the same * order. For testing, this makes comparison of old @@ -136,41 +136,41 @@ static int display_message(struct ldb_context *ldb, struct ldb_message *msg, str return 0; } -static int display_referral(char *referral, struct async_context *actx) { +static int display_referral(char *referral, struct search_context *sctx) { - actx->refs++; + sctx->refs++; printf("# Referral\nref: %s\n\n", referral); return 0; } -static int search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) +static int search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { - struct async_context *actx = talloc_get_type(context, struct async_context); + struct search_context *sctx = talloc_get_type(context, struct search_context); int ret; switch (ares->type) { case LDB_REPLY_ENTRY: - if (actx->sort) { - ret = store_message(ares->message, actx); + if (sctx->sort) { + ret = store_message(ares->message, sctx); } else { - ret = display_message(ldb, ares->message, actx); + ret = display_message(ldb, ares->message, sctx); } break; case LDB_REPLY_REFERRAL: - if (actx->sort) { - ret = store_referral(ares->referral, actx); + if (sctx->sort) { + ret = store_referral(ares->referral, sctx); } else { - ret = display_referral(ares->referral, actx); + ret = display_referral(ares->referral, sctx); } break; case LDB_REPLY_DONE: if (ares->controls) { - if (handle_controls_reply(ares->controls, actx->req_ctrls) == 1) - actx->pending = 1; + if (handle_controls_reply(ares->controls, sctx->req_ctrls) == 1) + sctx->pending = 1; } ret = 0; break; @@ -182,7 +182,7 @@ static int search_callback(struct ldb_context *ldb, void *context, struct ldb_as if (talloc_free(ares) == -1) { fprintf(stderr, "talloc_free failed\n"); - actx->pending = 0; + sctx->pending = 0; return LDB_ERR_OPERATIONS_ERROR; } @@ -200,22 +200,22 @@ static int do_search(struct ldb_context *ldb, const char * const *attrs) { struct ldb_request *req; - struct async_context *actx; + struct search_context *sctx; int ret; req = talloc(ldb, struct ldb_request); if (!req) return -1; - actx = talloc(req, struct async_context); - if (!actx) return -1; + sctx = talloc(req, struct search_context); + if (!sctx) return -1; - actx->sort = options->sorted; - actx->num_stored = 0; - actx->store = NULL; - actx->req_ctrls = parse_controls(ldb, options->controls); - if (options->controls != NULL && actx->req_ctrls== NULL) return -1; - actx->entries = 0; - actx->refs = 0; + sctx->sort = options->sorted; + sctx->num_stored = 0; + sctx->store = NULL; + sctx->req_ctrls = parse_controls(ldb, options->controls); + if (options->controls != NULL && sctx->req_ctrls== NULL) return -1; + sctx->entries = 0; + sctx->refs = 0; req->operation = LDB_SEARCH; req->op.search.base = basedn; @@ -223,13 +223,13 @@ static int do_search(struct ldb_context *ldb, req->op.search.tree = ldb_parse_tree(ldb, expression); if (req->op.search.tree == NULL) return -1; req->op.search.attrs = attrs; - req->controls = actx->req_ctrls; - req->async.context = actx; + req->controls = sctx->req_ctrls; + req->async.context = sctx; req->async.callback = &search_callback; ldb_set_timeout(ldb, req, 0); /* TODO: make this settable by command line */ again: - actx->pending = 0; + sctx->pending = 0; ret = ldb_request(ldb, req); if (ret != LDB_SUCCESS) { @@ -237,19 +237,19 @@ again: return -1; } - ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL); + ret = ldb_wait(req->async.handle, LDB_WAIT_ALL); if (ret != LDB_SUCCESS) { printf("search error - %s\n", ldb_errstring(ldb)); return -1; } - if (actx->pending) + if (sctx->pending) goto again; - if (actx->sort && actx->num_stored != 0) { + if (sctx->sort && sctx->num_stored != 0) { int i; - ldb_qsort(actx->store, ret, sizeof(struct ldb_message *), + ldb_qsort(sctx->store, ret, sizeof(struct ldb_message *), ldb, (ldb_qsort_cmp_fn_t)do_compare_msg); if (ret != 0) { @@ -257,17 +257,17 @@ again: exit(1); } - for (i = 0; i < actx->num_stored; i++) { - display_message(ldb, actx->store[i], actx); + for (i = 0; i < sctx->num_stored; i++) { + display_message(ldb, sctx->store[i], sctx); } - for (i = 0; i < actx->refs; i++) { - display_referral(actx->refs_store[i], actx); + for (i = 0; i < sctx->refs; i++) { + display_referral(sctx->refs_store[i], sctx); } } printf("# returned %d records\n# %d entries\n# %d referrals\n", - actx->entries + actx->refs, actx->entries, actx->refs); + sctx->entries + sctx->refs, sctx->entries, sctx->refs); talloc_free(req); -- cgit