1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

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 25fc735404)
This commit is contained in:
Simo Sorce
2006-07-22 16:56:33 +00:00
committed by Gerald (Jerry) Carter
parent 550f5fb26e
commit c93817b36d
24 changed files with 427 additions and 427 deletions

View File

@ -171,7 +171,7 @@ struct extended_async_context {
struct ldb_module *module; struct ldb_module *module;
void *up_context; 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; const char * const *attrs;
BOOL remove_guid; BOOL remove_guid;
@ -179,7 +179,7 @@ struct extended_async_context {
int extended_type; int extended_type;
}; };
static int extended_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) static int extended_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{ {
struct extended_async_context *ac; struct extended_async_context *ac;

View File

@ -102,12 +102,12 @@ struct kludge_acl_async_context {
struct ldb_module *module; struct ldb_module *module;
void *up_context; void *up_context;
int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *); int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
enum user_is user_type; enum user_is user_type;
}; };
static int kludge_acl_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) static int kludge_acl_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{ {
struct kludge_acl_async_context *ac; struct kludge_acl_async_context *ac;
struct kludge_private_data *data; struct kludge_private_data *data;

View File

@ -44,7 +44,7 @@ struct partition_private_data {
struct partition **partitions; struct partition **partitions;
}; };
struct partition_async_context { struct partition_context {
struct ldb_module *module; struct ldb_module *module;
struct ldb_request *orig_req; struct ldb_request *orig_req;
@ -53,12 +53,12 @@ struct partition_async_context {
int num_searches; int num_searches;
}; };
static struct ldb_async_handle *partition_init_handle(struct ldb_request *req, struct ldb_module *module) static struct ldb_handle *partition_init_handle(struct ldb_request *req, struct ldb_module *module)
{ {
struct partition_async_context *ac; struct partition_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(req, struct ldb_async_handle); h = talloc_zero(req, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -66,7 +66,7 @@ static struct ldb_async_handle *partition_init_handle(struct ldb_request *req, s
h->module = module; h->module = module;
ac = talloc_zero(h, struct partition_async_context); ac = talloc_zero(h, struct partition_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); talloc_free(h);
@ -118,7 +118,7 @@ struct ldb_module *find_backend(struct ldb_module *module, struct ldb_request *r
return module; return module;
}; };
static int partition_send_search(struct partition_async_context *ac, struct ldb_module *partition) static int partition_send_search(struct partition_context *ac, struct ldb_module *partition)
{ {
int ret; int ret;
struct ldb_module *next = make_module_for_next_request(ac->module, ac->module->ldb, partition); struct ldb_module *next = make_module_for_next_request(ac->module, ac->module->ldb, partition);
@ -159,8 +159,8 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req)
* partitions (for 'invisible' partition behaviour */ * partitions (for 'invisible' partition behaviour */
if (ldb_get_opaque(module->ldb, "global_catalog")) { if (ldb_get_opaque(module->ldb, "global_catalog")) {
int ret, i; int ret, i;
struct ldb_async_handle *h; struct ldb_handle *h;
struct partition_async_context *ac; struct partition_context *ac;
h = partition_init_handle(req, module); h = partition_init_handle(req, module);
if (!h) { if (!h) {
@ -169,7 +169,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req)
/* return our own handle to deal with this call */ /* return our own handle to deal with this call */
req->async.handle = h; req->async.handle = h;
ac = talloc_get_type(h->private_data, struct partition_async_context); ac = talloc_get_type(h->private_data, struct partition_context);
ac->orig_req = req; ac->orig_req = req;
ac->num_searches = 0; ac->num_searches = 0;
@ -518,8 +518,8 @@ static int partition_init(struct ldb_module *module)
return ldb_next_init(module); return ldb_next_init(module);
} }
static int partition_async_wait_none(struct ldb_async_handle *handle) { static int partition_wait_none(struct ldb_handle *handle) {
struct partition_async_context *ac; struct partition_context *ac;
int ret; int ret;
int i; int i;
@ -534,10 +534,10 @@ static int partition_async_wait_none(struct ldb_async_handle *handle) {
handle->state = LDB_ASYNC_PENDING; handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS; handle->status = LDB_SUCCESS;
ac = talloc_get_type(handle->private_data, struct partition_async_context); ac = talloc_get_type(handle->private_data, struct partition_context);
for (i=0; i < ac->num_searches; i++) { for (i=0; i < ac->num_searches; i++) {
ret = ldb_async_wait(ac->search_req[i]->async.handle, LDB_WAIT_NONE); ret = ldb_wait(ac->search_req[i]->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -561,12 +561,12 @@ done:
} }
static int partition_async_wait_all(struct ldb_async_handle *handle) { static int partition_wait_all(struct ldb_handle *handle) {
int ret; int ret;
while (handle->state != LDB_ASYNC_DONE) { while (handle->state != LDB_ASYNC_DONE) {
ret = partition_async_wait_none(handle); ret = partition_wait_none(handle);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
return ret; return ret;
} }
@ -575,12 +575,12 @@ static int partition_async_wait_all(struct ldb_async_handle *handle) {
return handle->status; return handle->status;
} }
static int partition_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) static int partition_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{ {
if (type == LDB_WAIT_ALL) { if (type == LDB_WAIT_ALL) {
return partition_async_wait_all(handle); return partition_wait_all(handle);
} else { } else {
return partition_async_wait_none(handle); return partition_wait_none(handle);
} }
} }
@ -596,7 +596,7 @@ static const struct ldb_module_ops partition_ops = {
.end_transaction = partition_end_trans, .end_transaction = partition_end_trans,
.del_transaction = partition_del_trans, .del_transaction = partition_del_trans,
.sequence_number = partition_sequence_number, .sequence_number = partition_sequence_number,
.async_wait = partition_async_wait .wait = partition_wait
}; };
int ldb_partition_init(void) int ldb_partition_init(void)

View File

@ -65,7 +65,7 @@
* *
*/ */
struct ph_async_context { struct ph_context {
enum ph_type {PH_ADD, PH_MOD} type; enum ph_type {PH_ADD, PH_MOD} type;
enum ph_step {PH_ADD_SEARCH_DOM, PH_ADD_DO_ADD, PH_MOD_DO_REQ, PH_MOD_SEARCH_SELF, PH_MOD_SEARCH_DOM, PH_MOD_DO_MOD} step; enum ph_step {PH_ADD_SEARCH_DOM, PH_ADD_DO_ADD, PH_MOD_DO_REQ, PH_MOD_SEARCH_SELF, PH_MOD_SEARCH_DOM, PH_MOD_DO_MOD} step;
@ -74,12 +74,12 @@ struct ph_async_context {
struct ldb_request *orig_req; struct ldb_request *orig_req;
struct ldb_request *dom_req; struct ldb_request *dom_req;
struct ldb_async_result *dom_res; struct ldb_reply *dom_res;
struct ldb_request *down_req; struct ldb_request *down_req;
struct ldb_request *search_req; struct ldb_request *search_req;
struct ldb_async_result *search_res; struct ldb_reply *search_res;
struct ldb_request *mod_req; struct ldb_request *mod_req;
@ -418,12 +418,12 @@ static int setPwdHistory(struct ldb_module *module, struct ldb_message *msg, str
return LDB_SUCCESS; return LDB_SUCCESS;
} }
static struct ldb_async_handle *ph_init_handle(struct ldb_request *req, struct ldb_module *module, enum ph_type type) static struct ldb_handle *ph_init_handle(struct ldb_request *req, struct ldb_module *module, enum ph_type type)
{ {
struct ph_async_context *ac; struct ph_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(req, struct ldb_async_handle); h = talloc_zero(req, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -431,7 +431,7 @@ static struct ldb_async_handle *ph_init_handle(struct ldb_request *req, struct l
h->module = module; h->module = module;
ac = talloc_zero(h, struct ph_async_context); ac = talloc_zero(h, struct ph_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); talloc_free(h);
@ -450,16 +450,16 @@ static struct ldb_async_handle *ph_init_handle(struct ldb_request *req, struct l
return h; return h;
} }
static int get_domain_data_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) static int get_domain_data_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{ {
struct ph_async_context *ac; struct ph_context *ac;
if (!context || !ares) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
ac = talloc_get_type(context, struct ph_async_context); ac = talloc_get_type(context, struct ph_context);
/* we are interested only in the single reply (base search) we receive here */ /* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) { if (ares->type == LDB_REPLY_ENTRY) {
@ -476,7 +476,7 @@ static int get_domain_data_callback(struct ldb_context *ldb, void *context, stru
return LDB_SUCCESS; return LDB_SUCCESS;
} }
static int build_domain_data_request(struct ph_async_context *ac) static int build_domain_data_request(struct ph_context *ac)
{ {
/* attrs[] is returned from this function in /* attrs[] is returned from this function in
ac->dom_req->op.search.attrs, so it must be static, as ac->dom_req->op.search.attrs, so it must be static, as
@ -517,13 +517,13 @@ static int build_domain_data_request(struct ph_async_context *ac)
return LDB_SUCCESS; return LDB_SUCCESS;
} }
static struct domain_data *get_domain_data(struct ldb_module *module, void *ctx, struct ldb_async_result *res) static struct domain_data *get_domain_data(struct ldb_module *module, void *ctx, struct ldb_reply *res)
{ {
struct domain_data *data; struct domain_data *data;
const char *tmp; const char *tmp;
struct ph_async_context *ac; struct ph_context *ac;
ac = talloc_get_type(ctx, struct ph_async_context); ac = talloc_get_type(ctx, struct ph_context);
data = talloc_zero(ac, struct domain_data); data = talloc_zero(ac, struct domain_data);
if (data == NULL) { if (data == NULL) {
@ -558,8 +558,8 @@ static struct domain_data *get_domain_data(struct ldb_module *module, void *ctx,
static int password_hash_add(struct ldb_module *module, struct ldb_request *req) static int password_hash_add(struct ldb_module *module, struct ldb_request *req)
{ {
struct ldb_async_handle *h; struct ldb_handle *h;
struct ph_async_context *ac; struct ph_context *ac;
struct ldb_message_element *sambaAttr; struct ldb_message_element *sambaAttr;
struct ldb_message_element *ntAttr; struct ldb_message_element *ntAttr;
struct ldb_message_element *lmAttr; struct ldb_message_element *lmAttr;
@ -621,7 +621,7 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req)
if (!h) { if (!h) {
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
ac = talloc_get_type(h->private_data, struct ph_async_context); ac = talloc_get_type(h->private_data, struct ph_context);
/* get user domain data */ /* get user domain data */
ac->domain_sid = samdb_result_sid_prefix(ac, req->op.add.message, "objectSid"); ac->domain_sid = samdb_result_sid_prefix(ac, req->op.add.message, "objectSid");
@ -642,16 +642,16 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, ac->dom_req); return ldb_next_request(module, ac->dom_req);
} }
static int password_hash_add_do_add(struct ldb_async_handle *h) { static int password_hash_add_do_add(struct ldb_handle *h) {
struct ph_async_context *ac; struct ph_context *ac;
struct domain_data *domain; struct domain_data *domain;
struct smb_krb5_context *smb_krb5_context; struct smb_krb5_context *smb_krb5_context;
struct ldb_message_element *sambaAttr; struct ldb_message_element *sambaAttr;
struct ldb_message *msg; struct ldb_message *msg;
int ret; int ret;
ac = talloc_get_type(h->private_data, struct ph_async_context); ac = talloc_get_type(h->private_data, struct ph_context);
domain = get_domain_data(ac->module, ac, ac->dom_res); domain = get_domain_data(ac->module, ac, ac->dom_res);
if (domain == NULL) { if (domain == NULL) {
@ -731,12 +731,12 @@ static int password_hash_add_do_add(struct ldb_async_handle *h) {
return ldb_next_request(ac->module, ac->down_req); return ldb_next_request(ac->module, ac->down_req);
} }
static int password_hash_mod_search_self(struct ldb_async_handle *h); static int password_hash_mod_search_self(struct ldb_handle *h);
static int password_hash_modify(struct ldb_module *module, struct ldb_request *req) static int password_hash_modify(struct ldb_module *module, struct ldb_request *req)
{ {
struct ldb_async_handle *h; struct ldb_handle *h;
struct ph_async_context *ac; struct ph_context *ac;
struct ldb_message_element *sambaAttr; struct ldb_message_element *sambaAttr;
struct ldb_message_element *ntAttr; struct ldb_message_element *ntAttr;
struct ldb_message_element *lmAttr; struct ldb_message_element *lmAttr;
@ -784,7 +784,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r
if (!h) { if (!h) {
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
ac = talloc_get_type(h->private_data, struct ph_async_context); ac = talloc_get_type(h->private_data, struct ph_context);
/* return or own handle to deal with this call */ /* return or own handle to deal with this call */
req->async.handle = h; req->async.handle = h;
@ -824,16 +824,16 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r
return ldb_next_request(module, ac->down_req); return ldb_next_request(module, ac->down_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 ph_async_context *ac; struct ph_context *ac;
if (!context || !ares) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
ac = talloc_get_type(context, struct ph_async_context); ac = talloc_get_type(context, struct ph_context);
/* we are interested only in the single reply (base search) we receive here */ /* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) { if (ares->type == LDB_REPLY_ENTRY) {
@ -859,9 +859,9 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
return LDB_SUCCESS; return LDB_SUCCESS;
} }
static int password_hash_mod_search_self(struct ldb_async_handle *h) { static int password_hash_mod_search_self(struct ldb_handle *h) {
struct ph_async_context *ac; struct ph_context *ac;
static const char * const attrs[] = { "userAccountControl", "sambaLMPwdHistory", static const char * const attrs[] = { "userAccountControl", "sambaLMPwdHistory",
"sambaNTPwdHistory", "sambaNTPwdHistory",
"objectSid", "msDS-KeyVersionNumber", "objectSid", "msDS-KeyVersionNumber",
@ -870,7 +870,7 @@ static int password_hash_mod_search_self(struct ldb_async_handle *h) {
"lmPwdHash", "ntPwdHash", "lmPwdHash", "ntPwdHash",
NULL }; NULL };
ac = talloc_get_type(h->private_data, struct ph_async_context); ac = talloc_get_type(h->private_data, struct ph_context);
/* prepare the search operation */ /* prepare the search operation */
ac->search_req = talloc_zero(ac, struct ldb_request); ac->search_req = talloc_zero(ac, struct ldb_request);
@ -898,12 +898,12 @@ static int password_hash_mod_search_self(struct ldb_async_handle *h) {
return ldb_next_request(ac->module, ac->search_req); return ldb_next_request(ac->module, ac->search_req);
} }
static int password_hash_mod_search_dom(struct ldb_async_handle *h) { static int password_hash_mod_search_dom(struct ldb_handle *h) {
struct ph_async_context *ac; struct ph_context *ac;
int ret; int ret;
ac = talloc_get_type(h->private_data, struct ph_async_context); ac = talloc_get_type(h->private_data, struct ph_context);
/* get object domain sid */ /* get object domain sid */
ac->domain_sid = samdb_result_sid_prefix(ac, ac->search_res->message, "objectSid"); ac->domain_sid = samdb_result_sid_prefix(ac, ac->search_res->message, "objectSid");
@ -923,9 +923,9 @@ static int password_hash_mod_search_dom(struct ldb_async_handle *h) {
return ldb_next_request(ac->module, ac->dom_req); return ldb_next_request(ac->module, ac->dom_req);
} }
static int password_hash_mod_do_mod(struct ldb_async_handle *h) { static int password_hash_mod_do_mod(struct ldb_handle *h) {
struct ph_async_context *ac; struct ph_context *ac;
struct domain_data *domain; struct domain_data *domain;
struct smb_krb5_context *smb_krb5_context; struct smb_krb5_context *smb_krb5_context;
struct ldb_message_element *sambaAttr; struct ldb_message_element *sambaAttr;
@ -934,7 +934,7 @@ static int password_hash_mod_do_mod(struct ldb_async_handle *h) {
int ret; int ret;
BOOL added_hashes = False; BOOL added_hashes = False;
ac = talloc_get_type(h->private_data, struct ph_async_context); ac = talloc_get_type(h->private_data, struct ph_context);
domain = get_domain_data(ac->module, ac, ac->dom_res); domain = get_domain_data(ac->module, ac, ac->dom_res);
if (domain == NULL) { if (domain == NULL) {
@ -1060,8 +1060,8 @@ static int password_hash_mod_do_mod(struct ldb_async_handle *h) {
return ldb_next_request(ac->module, ac->mod_req); return ldb_next_request(ac->module, ac->mod_req);
} }
static int ph_async_wait(struct ldb_async_handle *handle) { static int ph_wait(struct ldb_handle *handle) {
struct ph_async_context *ac; struct ph_context *ac;
int ret; int ret;
if (!handle || !handle->private_data) { if (!handle || !handle->private_data) {
@ -1075,11 +1075,11 @@ static int ph_async_wait(struct ldb_async_handle *handle) {
handle->state = LDB_ASYNC_PENDING; handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS; handle->status = LDB_SUCCESS;
ac = talloc_get_type(handle->private_data, struct ph_async_context); ac = talloc_get_type(handle->private_data, struct ph_context);
switch (ac->step) { switch (ac->step) {
case PH_ADD_SEARCH_DOM: case PH_ADD_SEARCH_DOM:
ret = ldb_async_wait(ac->dom_req->async.handle, LDB_WAIT_NONE); ret = ldb_wait(ac->dom_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -1098,7 +1098,7 @@ static int ph_async_wait(struct ldb_async_handle *handle) {
return password_hash_add_do_add(handle); return password_hash_add_do_add(handle);
case PH_ADD_DO_ADD: case PH_ADD_DO_ADD:
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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -1116,7 +1116,7 @@ static int ph_async_wait(struct ldb_async_handle *handle) {
break; break;
case PH_MOD_DO_REQ: case PH_MOD_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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -1135,7 +1135,7 @@ static int ph_async_wait(struct ldb_async_handle *handle) {
return password_hash_mod_search_self(handle); return password_hash_mod_search_self(handle);
case PH_MOD_SEARCH_SELF: case PH_MOD_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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -1154,7 +1154,7 @@ static int ph_async_wait(struct ldb_async_handle *handle) {
return password_hash_mod_search_dom(handle); return password_hash_mod_search_dom(handle);
case PH_MOD_SEARCH_DOM: case PH_MOD_SEARCH_DOM:
ret = ldb_async_wait(ac->dom_req->async.handle, LDB_WAIT_NONE); ret = ldb_wait(ac->dom_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -1173,7 +1173,7 @@ static int ph_async_wait(struct ldb_async_handle *handle) {
return password_hash_mod_do_mod(handle); return password_hash_mod_do_mod(handle);
case PH_MOD_DO_MOD: case PH_MOD_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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -1202,12 +1202,12 @@ done:
return ret; return ret;
} }
static int ph_async_wait_all(struct ldb_async_handle *handle) { static int ph_wait_all(struct ldb_handle *handle) {
int ret; int ret;
while (handle->state != LDB_ASYNC_DONE) { while (handle->state != LDB_ASYNC_DONE) {
ret = ph_async_wait(handle); ret = ph_wait(handle);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
return ret; return ret;
} }
@ -1216,12 +1216,12 @@ static int ph_async_wait_all(struct ldb_async_handle *handle) {
return handle->status; return handle->status;
} }
static int password_hash_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type) static int password_hash_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{ {
if (type == LDB_WAIT_ALL) { if (type == LDB_WAIT_ALL) {
return ph_async_wait_all(handle); return ph_wait_all(handle);
} else { } else {
return ph_async_wait(handle); return ph_wait(handle);
} }
} }
@ -1229,7 +1229,7 @@ static const struct ldb_module_ops password_hash_ops = {
.name = "password_hash", .name = "password_hash",
.add = password_hash_add, .add = password_hash_add,
.modify = password_hash_modify, .modify = password_hash_modify,
.async_wait = password_hash_async_wait .wait = password_hash_wait
}; };

View File

@ -142,12 +142,12 @@ failed:
struct rootdse_async_context { struct rootdse_async_context {
struct ldb_module *module; struct ldb_module *module;
void *up_context; 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; const char * const * attrs;
}; };
static int rootdse_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) static int rootdse_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{ {
struct rootdse_async_context *ac; struct rootdse_async_context *ac;

View File

@ -113,7 +113,7 @@ NTSTATUS ldapsrv_unwilling(struct ldapsrv_call *call, int error)
return NT_STATUS_OK; return NT_STATUS_OK;
} }
static int ldapsrv_SearchCallback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) static int ldapsrv_SearchCallback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{ {
struct ldb_result *res; struct ldb_result *res;
int n; int n;
@ -262,7 +262,7 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
goto reply; goto reply;
} }
ldb_ret = ldb_async_wait(lreq->async.handle, LDB_WAIT_ALL); ldb_ret = ldb_wait(lreq->async.handle, LDB_WAIT_ALL);
if (ldb_ret == LDB_SUCCESS) { if (ldb_ret == LDB_SUCCESS) {
for (i = 0; i < res->count; i++) { for (i = 0; i < res->count; i++) {

View File

@ -335,7 +335,7 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque
ret = ldb_request(ldb, req); ret = ldb_request(ldb, req);
if (ret == LDB_SUCCESS) { 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) { if (ret == LDB_SUCCESS) {
@ -353,13 +353,13 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque
return ret; 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) { if (!handle) {
return LDB_SUCCESS; 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 */ /* 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 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; struct ldb_result *res;
int n; int n;
@ -563,7 +563,7 @@ int ldb_search(struct ldb_context *ldb,
ret = ldb_request(ldb, req); ret = ldb_request(ldb, req);
if (ret == LDB_SUCCESS) { 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) { if (ret != LDB_SUCCESS) {

View File

@ -578,12 +578,12 @@ enum ldb_reply_type {
LDB_REPLY_DONE LDB_REPLY_DONE
}; };
enum ldb_async_wait_type { enum ldb_wait_type {
LDB_WAIT_ALL, LDB_WAIT_ALL,
LDB_WAIT_NONE LDB_WAIT_NONE
}; };
enum ldb_async_state { enum ldb_state {
LDB_ASYNC_INIT, LDB_ASYNC_INIT,
LDB_ASYNC_PENDING, LDB_ASYNC_PENDING,
LDB_ASYNC_DONE LDB_ASYNC_DONE
@ -596,16 +596,16 @@ struct ldb_result {
struct ldb_control **controls; struct ldb_control **controls;
}; };
struct ldb_async_result { struct ldb_reply {
enum ldb_reply_type type; enum ldb_reply_type type;
struct ldb_message *message; struct ldb_message *message;
char *referral; char *referral;
struct ldb_control **controls; struct ldb_control **controls;
}; };
struct ldb_async_handle { struct ldb_handle {
int status; int status;
enum ldb_async_state state; enum ldb_state state;
void *private_data; void *private_data;
struct ldb_module *module; struct ldb_module *module;
}; };
@ -666,17 +666,17 @@ struct ldb_request {
struct { struct {
void *context; void *context;
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
int timeout; int timeout;
time_t starttime; time_t starttime;
struct ldb_async_handle *handle; struct ldb_handle *handle;
} async; } async;
}; };
int ldb_request(struct ldb_context *ldb, struct ldb_request *request); 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(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); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq);

View File

@ -66,7 +66,7 @@ struct ldb_module_ops {
int (*start_transaction)(struct ldb_module *); int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *);
int (*del_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 *); int (*sequence_number)(struct ldb_module *, struct ldb_request *);
}; };

View File

@ -56,11 +56,11 @@ struct ildb_private {
struct ldb_context *ldb; struct ldb_context *ldb;
}; };
struct ildb_async_context { struct ildb_context {
struct ldb_module *module; struct ldb_module *module;
struct ldap_request *req; struct ldap_request *req;
void *context; 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, static void ildb_request_timeout(struct event_context *ev, struct timed_event *te,
struct timeval t, void *private_data) struct timeval t, void *private_data)
{ {
struct ldb_async_handle *handle = talloc_get_type(private_data, struct ldb_async_handle); struct ldb_handle *handle = talloc_get_type(private_data, struct ldb_handle);
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 (ac->req->state == LDAP_REQUEST_PENDING) { if (ac->req->state == LDAP_REQUEST_PENDING) {
DLIST_REMOVE(ac->req->conn->pending, ac->req); 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) 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 ldb_handle *handle = talloc_get_type(req->async.private_data, struct ldb_handle);
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);
struct ildb_private *ildb = talloc_get_type(ac->module->private_data, struct ildb_private); struct ildb_private *ildb = talloc_get_type(ac->module->private_data, struct ildb_private);
NTSTATUS status; NTSTATUS status;
int i; int i;
@ -230,11 +230,11 @@ static void ildb_callback(struct ldap_request *req)
/* loop over all messages */ /* loop over all messages */
for (i = 0; i < req->num_replies; i++) { for (i = 0; i < req->num_replies; i++) {
struct ldap_SearchResEntry *search; struct ldap_SearchResEntry *search;
struct ldb_async_result *ares = NULL; struct ldb_reply *ares = NULL;
struct ldap_message *msg; struct ldap_message *msg;
int ret; int ret;
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (!ares) { if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
return; 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, static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg,
void *context, void *context,
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
int timeout, 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_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ildb_async_context *ildb_ac; struct ildb_context *ildb_ac;
struct ldb_async_handle *h; struct ldb_handle *h;
struct ldap_request *req; struct ldap_request *req;
h = talloc_zero(ildb->ldap, struct ldb_async_handle); h = talloc_zero(ildb->ldap, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return LDB_ERR_OPERATIONS_ERROR; 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; h->module = module;
ildb_ac = talloc(h, struct ildb_async_context); ildb_ac = talloc(h, struct ildb_context);
if (ildb_ac == NULL) { if (ildb_ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); talloc_free(h);
@ -665,9 +665,9 @@ static int ildb_request(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR; 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) { if (handle->state == LDB_ASYNC_DONE) {
return handle->status; return handle->status;
@ -699,7 +699,7 @@ static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_
return handle->status; 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; struct ildb_private *ildb;
@ -767,7 +767,7 @@ static int ildb_init(struct ldb_module *module)
return ret; return ret;
} }
ret = ildb_async_wait(req->async.handle, LDB_WAIT_ALL); ret = ildb_wait(req->async.handle, LDB_WAIT_ALL);
talloc_free(req); talloc_free(req);
return ret; return ret;
@ -784,7 +784,7 @@ static const struct ldb_module_ops ildb_ops = {
.start_transaction = ildb_start_trans, .start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans, .end_transaction = ildb_end_trans,
.del_transaction = ildb_del_trans, .del_transaction = ildb_del_trans,
.async_wait = ildb_async_wait, .wait = ildb_wait,
.init_context = ildb_init .init_context = ildb_init
}; };

View File

@ -49,13 +49,13 @@ struct lldb_private {
LDAP *ldap; LDAP *ldap;
}; };
struct lldb_async_context { struct lldb_context {
struct ldb_module *module; struct ldb_module *module;
int msgid; int msgid;
int timeout; int timeout;
time_t starttime; time_t starttime;
void *context; 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) { static int lldb_ldap_to_ldb(int err) {
@ -63,15 +63,15 @@ static int lldb_ldap_to_ldb(int err) {
return 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, 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) int timeout, time_t starttime)
{ {
struct lldb_async_context *ac; struct lldb_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(lldb, struct ldb_async_handle); h = talloc_zero(lldb, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -79,7 +79,7 @@ static struct ldb_async_handle *init_handle(struct lldb_private *lldb, struct ld
h->module = module; h->module = module;
ac = talloc(h, struct lldb_async_context); ac = talloc(h, struct lldb_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); 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) 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_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; struct timeval tv;
int ldap_scope; int ldap_scope;
char *search_base; char *search_base;
@ -255,7 +255,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR; 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); search_base = ldb_dn_linearize(lldb_ac, req->op.search.base);
if (req->op.search.base == NULL) { 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) 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_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac; struct lldb_context *lldb_ac;
LDAPMod **mods; LDAPMod **mods;
char *dn; char *dn;
int ret; int ret;
@ -323,7 +323,7 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR; 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); mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0);
if (mods == NULL) { 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) 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_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac; struct lldb_context *lldb_ac;
LDAPMod **mods; LDAPMod **mods;
char *dn; char *dn;
int ret; int ret;
@ -368,7 +368,7 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR; 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); mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1);
if (mods == NULL) { 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) 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_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac; struct lldb_context *lldb_ac;
char *dnstr; char *dnstr;
int ret; int ret;
@ -412,7 +412,7 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR; 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); 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) 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_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 *old_dn;
char *newrdn; char *newrdn;
char *parentdn; char *parentdn;
@ -450,7 +450,7 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR; 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); old_dn = ldb_dn_linearize(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) { 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); 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 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; LDAPMessage *msg;
int type; int type;
char *matcheddnp = NULL; char *matcheddnp = NULL;
@ -503,7 +503,7 @@ static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *resul
BerElement *berptr = NULL; BerElement *berptr = NULL;
char *attr, *dn; char *attr, *dn;
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (!ares) { if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
goto error; goto error;
@ -566,7 +566,7 @@ static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *resul
goto error; goto error;
} }
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (!ares) { if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
goto error; goto error;
@ -586,7 +586,7 @@ static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *resul
goto error; goto error;
} }
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (!ares) { if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
goto error; goto error;
@ -642,9 +642,9 @@ error:
return ret; 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 lldb_private *lldb = talloc_get_type(handle->module->private_data, struct lldb_private);
struct timeval timeout; struct timeval timeout;
LDAPMessage *result; LDAPMessage *result;
@ -758,7 +758,7 @@ static const struct ldb_module_ops lldb_ops = {
.start_transaction = lldb_start_trans, .start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans, .end_transaction = lldb_end_trans,
.del_transaction = lldb_del_trans, .del_transaction = lldb_del_trans,
.async_wait = lldb_async_wait .wait = lldb_wait
}; };

View File

@ -44,27 +44,27 @@ struct lsqlite3_private {
sqlite3 *sqlite; sqlite3 *sqlite;
}; };
struct lsql_async_context { struct lsql_context {
struct ldb_module *module; struct ldb_module *module;
/* search stuff */ /* search stuff */
long long current_eid; long long current_eid;
const char * const * attrs; const char * const * attrs;
struct ldb_async_result *ares; struct ldb_reply *ares;
/* async stuff */ /* async stuff */
void *context; 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, 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 lsql_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(lsqlite3, struct ldb_async_handle); h = talloc_zero(lsqlite3, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -72,7 +72,7 @@ static struct ldb_async_handle *init_handle(struct lsqlite3_private *lsqlite3, s
h->module = module; h->module = module;
ac = talloc(h, struct lsql_async_context); ac = talloc(h, struct lsql_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); 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) 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 ldb_handle *handle = talloc_get_type(result, struct ldb_handle);
struct lsql_async_context *ac = talloc_get_type(handle->private_data, struct lsql_async_context); struct lsql_context *ac = talloc_get_type(handle->private_data, struct lsql_context);
struct ldb_message *msg; struct ldb_message *msg;
long long eid; long long eid;
int i; int i;
@ -738,7 +738,7 @@ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char
} }
/* start over */ /* start over */
ac->ares = talloc_zero(ac, struct ldb_async_result); ac->ares = talloc_zero(ac, struct ldb_reply);
if (!ac->ares) if (!ac->ares)
return SQLITE_ABORT; return SQLITE_ABORT;
@ -842,7 +842,7 @@ done:
* Interface functions referenced by lsqlite3_ops * 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; 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, enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const *attrs, const char * const *attrs,
void *context, void *context,
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
struct ldb_async_handle **handle) struct ldb_handle **handle)
{ {
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); 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 *norm_basedn;
char *sqlfilter; char *sqlfilter;
char *errmsg; char *errmsg;
@ -908,7 +908,7 @@ int lsql_search_async(struct ldb_module *module, const struct ldb_dn *base,
return LDB_ERR_OPERATIONS_ERROR; 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) { if (base) {
norm_basedn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, 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, enum ldb_scope scope, struct ldb_parse_tree * tree,
const char * const * attrs, struct ldb_result ** res) const char * const * attrs, struct ldb_result ** res)
{ {
struct ldb_async_handle *handle; struct ldb_handle *handle;
int ret; int ret;
*res = talloc_zero(module, struct ldb_result); *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); &handle);
if (ret == LDB_SUCCESS) { if (ret == LDB_SUCCESS) {
ret = ldb_async_wait(handle, LDB_WAIT_ALL); ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle); talloc_free(handle);
} }
@ -1102,11 +1102,11 @@ static int lsql_search_bytree(struct ldb_module * module, const struct ldb_dn* b
/* add a record */ /* add a record */
static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg, static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg,
void *context, void *context,
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
struct ldb_async_handle **handle) struct ldb_handle **handle)
{ {
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); 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; long long eid;
char *dn, *ndn; char *dn, *ndn;
char *errmsg; char *errmsg;
@ -1118,7 +1118,7 @@ static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg,
if (*handle == NULL) { if (*handle == NULL) {
goto failed; 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)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS; (*handle)->status = LDB_SUCCESS;
@ -1242,7 +1242,7 @@ failed:
static int lsql_add(struct ldb_module *module, const struct ldb_message *msg) static int lsql_add(struct ldb_module *module, const struct ldb_message *msg)
{ {
struct ldb_async_handle *handle; struct ldb_handle *handle;
int ret; int ret;
ret = lsql_add_async(module, msg, NULL, NULL, &handle); 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) if (ret != LDB_SUCCESS)
return ret; return ret;
ret = ldb_async_wait(handle, LDB_WAIT_ALL); ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle); talloc_free(handle);
return ret; return ret;
@ -1260,11 +1260,11 @@ static int lsql_add(struct ldb_module *module, const struct ldb_message *msg)
/* modify a record */ /* modify a record */
static int lsql_modify_async(struct ldb_module *module, const struct ldb_message *msg, static int lsql_modify_async(struct ldb_module *module, const struct ldb_message *msg,
void *context, void *context,
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
struct ldb_async_handle **handle) struct ldb_handle **handle)
{ {
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); 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; long long eid;
char *errmsg; char *errmsg;
int i; int i;
@ -1274,7 +1274,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message
if (*handle == NULL) { if (*handle == NULL) {
goto failed; 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)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS; (*handle)->status = LDB_SUCCESS;
@ -1456,7 +1456,7 @@ failed:
static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg) static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg)
{ {
struct ldb_async_handle *handle; struct ldb_handle *handle;
int ret; int ret;
ret = lsql_modify_async(module, msg, NULL, NULL, &handle); 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) if (ret != LDB_SUCCESS)
return ret; return ret;
ret = ldb_async_wait(handle, LDB_WAIT_ALL); ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle); talloc_free(handle);
return ret; return ret;
@ -1473,11 +1473,11 @@ static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg)
/* delete a record */ /* delete a record */
static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn, static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
void *context, void *context,
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
struct ldb_async_handle **handle) struct ldb_handle **handle)
{ {
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); 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; long long eid;
char *errmsg; char *errmsg;
char *query; char *query;
@ -1488,7 +1488,7 @@ static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
if (*handle == NULL) { if (*handle == NULL) {
goto failed; 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)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS; (*handle)->status = LDB_SUCCESS;
@ -1530,7 +1530,7 @@ failed:
static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn) static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn)
{ {
struct ldb_async_handle *handle; struct ldb_handle *handle;
int ret; int ret;
/* ignore ltdb specials */ /* ignore ltdb specials */
@ -1543,7 +1543,7 @@ static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn)
if (ret != LDB_SUCCESS) if (ret != LDB_SUCCESS)
return ret; return ret;
ret = ldb_async_wait(handle, LDB_WAIT_ALL); ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle); talloc_free(handle);
return ret; return ret;
@ -1552,11 +1552,11 @@ static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn)
/* rename a record */ /* rename a record */
static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn, static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn,
void *context, void *context,
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *), int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
struct ldb_async_handle **handle) struct ldb_handle **handle)
{ {
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); 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 *new_dn, *new_cdn, *old_cdn;
char *errmsg; char *errmsg;
char *query; char *query;
@ -1566,7 +1566,7 @@ static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *old
if (*handle == NULL) { if (*handle == NULL) {
goto failed; 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)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS; (*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) 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; int ret;
/* ignore ltdb specials */ /* 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) if (ret != LDB_SUCCESS)
return ret; return ret;
ret = ldb_async_wait(handle, LDB_WAIT_ALL); ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle); talloc_free(handle);
return ret; return ret;
@ -1971,7 +1971,7 @@ static int destructor(struct lsqlite3_private *lsqlite3)
return 0; 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; return handle->status;
} }
@ -2066,7 +2066,7 @@ static const struct ldb_module_ops lsqlite3_ops = {
.start_transaction = lsql_start_trans, .start_transaction = lsql_start_trans,
.end_transaction = lsql_end_trans, .end_transaction = lsql_end_trans,
.del_transaction = lsql_del_trans, .del_transaction = lsql_del_trans,
.async_wait = lsql_async_wait, .wait = lsql_wait,
}; };
/* /*

View File

@ -628,17 +628,17 @@ static int ltdb_index_dn(struct ldb_module *module,
extracting just the given attributes extracting just the given attributes
*/ */
static int ltdb_index_filter(const struct dn_list *dn_list, 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 ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
struct ldb_async_result *ares = NULL; struct ldb_reply *ares = NULL;
unsigned int i; unsigned int i;
for (i = 0; i < dn_list->count; i++) { for (i = 0; i < dn_list->count; i++) {
struct ldb_dn *dn; struct ldb_dn *dn;
int ret; int ret;
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (!ares) { if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
handle->state = LDB_ASYNC_DONE; 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 returns -1 if an indexed search is not possible, in which
case the caller should call ltdb_search_full() 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 ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
struct dn_list *dn_list; struct dn_list *dn_list;
int ret; int ret;

View File

@ -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) 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 ldb_handle *handle = talloc_get_type(state, struct ldb_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 ldb_async_result *ares = NULL; struct ldb_reply *ares = NULL;
int ret; int ret;
if (key.dsize < 4 || 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; return 0;
} }
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (!ares) { if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
handle->state = LDB_ASYNC_DONE; 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. search the database with a LDAP-like expression.
this is the "full search" non-indexed variant 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); struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
int ret; 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) 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_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
struct ltdb_async_context *ltdb_ac; struct ltdb_context *ltdb_ac;
int ret; int ret;
if ((req->op.search.base == NULL || req->op.search.base->comp_num == 0) && 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; 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->tree = req->op.search.tree;
ltdb_ac->scope = req->op.search.scope; ltdb_ac->scope = req->op.search.scope;

View File

@ -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, 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 ltdb_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(ltdb, struct ldb_async_handle); h = talloc_zero(ltdb, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -93,7 +93,7 @@ struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_
h->module = module; h->module = module;
ac = talloc_zero(h, struct ltdb_async_context); ac = talloc_zero(h, struct ltdb_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); 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) 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_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; int tret, ret = LDB_SUCCESS;
if (req->controls != NULL) { 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) { if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR; 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); tret = ltdb_add_internal(module, req->op.add.message);
if (tret != LDB_SUCCESS) { 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) 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_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; int tret, ret = LDB_SUCCESS;
if (req->controls != NULL) { 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) { if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR; 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); tret = ltdb_delete_internal(module, req->op.del.dn);
if (tret != LDB_SUCCESS) { if (tret != LDB_SUCCESS) {
@ -754,7 +754,7 @@ failed:
static int ltdb_modify(struct ldb_module *module, struct ldb_request *req) 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_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; int tret, ret = LDB_SUCCESS;
if (req->controls != NULL) { 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) { if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR; 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); tret = ltdb_check_special_dn(module, req->op.mod.message);
if (tret != LDB_SUCCESS) { if (tret != LDB_SUCCESS) {
@ -803,7 +803,7 @@ done:
static int ltdb_rename(struct ldb_module *module, struct ldb_request *req) 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_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; struct ldb_message *msg;
int tret, ret = LDB_SUCCESS; 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) { if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR; 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); msg = talloc(ltdb_ac, struct ldb_message);
if (msg == NULL) { if (msg == NULL) {
@ -901,7 +901,7 @@ static int ltdb_del_trans(struct ldb_module *module)
return LDB_SUCCESS; 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; return handle->status;
} }
@ -965,7 +965,7 @@ static const struct ldb_module_ops ltdb_ops = {
.start_transaction = ltdb_start_trans, .start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans, .end_transaction = ltdb_end_trans,
.del_transaction = ltdb_del_trans, .del_transaction = ltdb_del_trans,
.async_wait = ltdb_async_wait, .wait = ltdb_wait,
.sequence_number = ltdb_sequence_number .sequence_number = ltdb_sequence_number
}; };

View File

@ -33,7 +33,7 @@ struct ltdb_private {
the async local context the async local context
holds also internal search state during a full db search holds also internal search state during a full db search
*/ */
struct ltdb_async_context { struct ltdb_context {
struct ldb_module *module; struct ldb_module *module;
/* search stuff */ /* search stuff */
@ -44,7 +44,7 @@ struct ltdb_async_context {
/* async stuff */ /* async stuff */
void *context; void *context;
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
}; };
/* special record types */ /* special record types */
@ -71,7 +71,7 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value);
struct ldb_parse_tree; 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_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_index_del(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_reindex(struct ldb_module *module); 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); int ltdb_search(struct ldb_module *module, struct ldb_request *req);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */ /* 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, 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); 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_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); int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn);

View File

@ -41,20 +41,20 @@
#define ASQ_CTRL_UNWILLING_TO_PERFORM 53 #define ASQ_CTRL_UNWILLING_TO_PERFORM 53
#define ASQ_CTRL_AFFECTS_MULTIPLE_DSA 71 #define ASQ_CTRL_AFFECTS_MULTIPLE_DSA 71
struct asq_async_context { struct asq_context {
enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step; enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step;
struct ldb_module *module; struct ldb_module *module;
void *up_context; 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; const char * const *req_attrs;
char *req_attribute; char *req_attribute;
int asq_ret; int asq_ret;
struct ldb_request *base_req; struct ldb_request *base_req;
struct ldb_async_result *base_res; struct ldb_reply *base_res;
struct ldb_request **reqs; struct ldb_request **reqs;
int num_reqs; int num_reqs;
@ -63,14 +63,14 @@ struct asq_async_context {
struct ldb_control **controls; 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, 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 asq_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(mem_ctx, struct ldb_async_handle); h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -78,7 +78,7 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
h->module = module; h->module = module;
ac = talloc_zero(h, struct asq_async_context); ac = talloc_zero(h, struct asq_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); talloc_free(h);
@ -97,19 +97,19 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
return h; 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 asq_context *ac;
struct ldb_async_result *ares; struct ldb_reply *ares;
struct ldb_asq_control *asq; struct ldb_asq_control *asq;
int i; 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->status = LDB_SUCCESS;
handle->state = LDB_ASYNC_DONE; handle->state = LDB_ASYNC_DONE;
ares = talloc_zero(ac, struct ldb_async_result); ares = talloc_zero(ac, struct ldb_reply);
if (ares == NULL) if (ares == NULL)
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
@ -149,16 +149,16 @@ static int asq_terminate(struct ldb_async_handle *handle)
return LDB_SUCCESS; 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) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error; 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 */ /* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) { if (ares->type == LDB_REPLY_ENTRY) {
@ -173,16 +173,16 @@ error:
return LDB_ERR_OPERATIONS_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) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error; 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 */ /* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) { 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_control *control;
struct ldb_asq_control *asq_ctrl; struct ldb_asq_control *asq_ctrl;
struct asq_async_context *ac; struct asq_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
char **base_attrs; char **base_attrs;
int ret; int ret;
@ -234,7 +234,7 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
if (!h) { if (!h) {
return LDB_ERR_OPERATIONS_ERROR; 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; req->async.handle = h;
@ -281,12 +281,12 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
return LDB_SUCCESS; return LDB_SUCCESS;
} }
static int asq_async_requests(struct ldb_async_handle *handle) { static int asq_requests(struct ldb_handle *handle) {
struct asq_async_context *ac; struct asq_context *ac;
struct ldb_message_element *el; struct ldb_message_element *el;
int i; 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 */ /* look up the DNs */
el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute); 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; 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; int ret;
if (!handle || !handle->private_data) { 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->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS; 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) { switch (ac->step) {
case ASQ_SEARCH_BASE: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -365,7 +365,7 @@ static int asq_async_wait_none(struct ldb_async_handle *handle)
return LDB_SUCCESS; return LDB_SUCCESS;
} }
ret = asq_async_requests(handle); ret = asq_requests(handle);
case ASQ_SEARCH_MULTI: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -408,12 +408,12 @@ done:
return ret; return ret;
} }
static int asq_async_wait_all(struct ldb_async_handle *handle) static int asq_wait_all(struct ldb_handle *handle)
{ {
int ret; int ret;
while (handle->state != LDB_ASYNC_DONE) { while (handle->state != LDB_ASYNC_DONE) {
ret = asq_async_wait_none(handle); ret = asq_wait_none(handle);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
return ret; return ret;
} }
@ -422,12 +422,12 @@ static int asq_async_wait_all(struct ldb_async_handle *handle)
return handle->status; 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) { if (type == LDB_WAIT_ALL) {
return asq_async_wait_all(handle); return asq_wait_all(handle);
} else { } 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 = { static const struct ldb_module_ops asq_ops = {
.name = "asq", .name = "asq",
.search = asq_search, .search = asq_search,
.async_wait = asq_async_wait, .wait = asq_wait,
.init_context = asq_init .init_context = asq_init
}; };

View File

@ -36,7 +36,7 @@
#include "includes.h" #include "includes.h"
#include "ldb/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; 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 *down_req;
struct ldb_request *search_req; struct ldb_request *search_req;
struct ldb_async_result *search_res; struct ldb_reply *search_res;
struct ldb_request *mod_req; struct ldb_request *mod_req;
}; };
@ -56,12 +56,12 @@ struct class_list {
const char *objectclass; 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 oc_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(req, struct ldb_async_handle); h = talloc_zero(req, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -69,7 +69,7 @@ static struct ldb_async_handle *oc_init_handle(struct ldb_request *req, struct l
h->module = module; h->module = module;
ac = talloc_zero(h, struct oc_async_context); ac = talloc_zero(h, struct oc_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); 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 ldb_handle *h;
struct oc_async_context *ac; struct oc_context *ac;
h = oc_init_handle(req, module); h = oc_init_handle(req, module);
if (!h) { if (!h) {
return LDB_ERR_OPERATIONS_ERROR; 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 */ /* return or own handle to deal with this call */
req->async.handle = h; 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) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
return LDB_ERR_OPERATIONS_ERROR; 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 */ /* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) { 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; 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 }; 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 */ /* prepare the search operation */
ac->search_req = talloc_zero(ac, struct ldb_request); 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); 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_element *objectclass_element;
struct ldb_message *msg; struct ldb_message *msg;
TALLOC_CTX *mem_ctx; TALLOC_CTX *mem_ctx;
struct class_list *sorted, *current; struct class_list *sorted, *current;
int ret; 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); mem_ctx = talloc_new(ac);
if (mem_ctx == NULL) { 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); return ldb_next_request(ac->module, ac->mod_req);
} }
static int oc_async_wait(struct ldb_async_handle *handle) { static int oc_wait(struct ldb_handle *handle) {
struct oc_async_context *ac; struct oc_context *ac;
int ret; int ret;
if (!handle || !handle->private_data) { 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->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS; 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) { switch (ac->step) {
case OC_DO_REQ: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -609,7 +609,7 @@ static int oc_async_wait(struct ldb_async_handle *handle) {
return objectclass_search_self(handle); return objectclass_search_self(handle);
case OC_SEARCH_SELF: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -628,7 +628,7 @@ static int oc_async_wait(struct ldb_async_handle *handle) {
return objectclass_do_mod(handle); return objectclass_do_mod(handle);
case OC_DO_MOD: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
@ -657,12 +657,12 @@ done:
return ret; return ret;
} }
static int oc_async_wait_all(struct ldb_async_handle *handle) { static int oc_wait_all(struct ldb_handle *handle) {
int ret; int ret;
while (handle->state != LDB_ASYNC_DONE) { while (handle->state != LDB_ASYNC_DONE) {
ret = oc_async_wait(handle); ret = oc_wait(handle);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
return ret; return ret;
} }
@ -671,12 +671,12 @@ static int oc_async_wait_all(struct ldb_async_handle *handle) {
return handle->status; 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) { if (type == LDB_WAIT_ALL) {
return oc_async_wait_all(handle); return oc_wait_all(handle);
} else { } else {
return oc_async_wait(handle); return oc_wait(handle);
} }
} }
@ -684,7 +684,7 @@ static const struct ldb_module_ops objectclass_ops = {
.name = "objectclass", .name = "objectclass",
.add = objectclass_add, .add = objectclass_add,
.modify = objectclass_modify, .modify = objectclass_modify,
.async_wait = objectclass_async_wait .wait = objectclass_wait
}; };
int ldb_objectclass_init(void) int ldb_objectclass_init(void)

View File

@ -230,12 +230,12 @@ struct operational_async_context {
struct ldb_module *module; struct ldb_module *module;
void *up_context; 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; 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; struct operational_async_context *ac;

View File

@ -37,10 +37,10 @@
#include "ldb/include/includes.h" #include "ldb/include/includes.h"
struct message_store { 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 * instead of freeing and talloc-ing the container
* on each result */ * on each result */
struct ldb_async_result *r; struct ldb_reply *r;
struct message_store *next; struct message_store *next;
}; };
@ -122,24 +122,24 @@ static struct results_store *new_store(struct private_data *priv)
return new; return new;
} }
struct paged_async_context { struct paged_context {
struct ldb_module *module; struct ldb_module *module;
void *up_context; 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; int size;
struct results_store *store; 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, 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 paged_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(mem_ctx, struct ldb_async_handle); h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -147,7 +147,7 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
h->module = module; h->module = module;
ac = talloc_zero(h, struct paged_async_context); ac = talloc_zero(h, struct paged_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); talloc_free(h);
@ -166,16 +166,16 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
return h; 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) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error; 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 (ares->type == LDB_REPLY_ENTRY) {
if (ac->store->first == NULL) { 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 private_data *private_data;
struct ldb_paged_control *paged_ctrl; struct ldb_paged_control *paged_ctrl;
struct ldb_control **saved_controls; struct ldb_control **saved_controls;
struct paged_async_context *ac; struct paged_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
int ret; int ret;
/* check if there's a paged request control */ /* 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) { if (!h) {
return LDB_ERR_OPERATIONS_ERROR; 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; 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.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); ldb_set_timeout_from_prev_req(module->ldb, req, ac->store->req);
ret = ldb_next_request(module, 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_paged_control *paged;
struct ldb_async_result *ares; struct ldb_reply *ares;
struct message_store *msg; struct message_store *msg;
int i, num_ctrls, ret; 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) if (ac->store == NULL)
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
@ -382,7 +382,7 @@ static int paged_results(struct ldb_async_handle *handle)
talloc_free(msg); talloc_free(msg);
} }
ares = talloc_zero(ac->store, struct ldb_async_result); ares = talloc_zero(ac->store, struct ldb_reply);
if (ares == NULL) { if (ares == NULL) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status; return handle->status;
@ -446,9 +446,9 @@ static int paged_results(struct ldb_async_handle *handle)
return ret; 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; int ret;
if (!handle || !handle->private_data) { 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; 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 (ac->store->req->async.handle->state == LDB_ASYNC_DONE) {
/* if lower level is finished we do not need to call it anymore */ /* 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) { if (type == LDB_WAIT_ALL) {
while (ac->store->req->async.handle->state != LDB_ASYNC_DONE) { 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) { if (ret != LDB_SUCCESS) {
handle->state = LDB_ASYNC_DONE; handle->state = LDB_ASYNC_DONE;
handle->status = ret; handle->status = ret;
@ -498,7 +498,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait
return ret; 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) { if (ret != LDB_SUCCESS) {
handle->state = LDB_ASYNC_DONE; handle->state = LDB_ASYNC_DONE;
handle->status = ret; handle->status = ret;
@ -560,7 +560,7 @@ static int paged_request_init(struct ldb_module *module)
static const struct ldb_module_ops paged_ops = { static const struct ldb_module_ops paged_ops = {
.name = "paged_results", .name = "paged_results",
.search = paged_search, .search = paged_search,
.async_wait = paged_async_wait, .wait = paged_wait,
.init_context = paged_request_init .init_context = paged_request_init
}; };

View File

@ -134,7 +134,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
return ret; return ret;
} }
struct rename_async_context { struct rename_context {
enum {RENAME_RENAME, RENAME_MODIFY} step; enum {RENAME_RENAME, RENAME_MODIFY} step;
struct ldb_request *orig_req; 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) static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
{ {
struct ldb_async_handle *h; struct ldb_handle *h;
struct rename_async_context *ac; struct rename_context *ac;
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); 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); return ldb_next_request(module, req);
} }
h = talloc_zero(req, struct ldb_async_handle); h = talloc_zero(req, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
h->module = module; h->module = module;
ac = talloc_zero(h, struct rename_async_context); ac = talloc_zero(h, struct rename_context);
if (ac == NULL) { if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR; 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); 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_dn_component *rdn;
struct ldb_message *msg; 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); rdn = ldb_dn_get_rdn(ac, ac->orig_req->op.rename.newdn);
if (rdn == NULL) { 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); 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; int ret;
if (!handle || !handle->private_data) { 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->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS; 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) { switch(ac->step) {
case RENAME_RENAME: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
goto done; goto done;
@ -272,7 +272,7 @@ static int rename_async_wait(struct ldb_async_handle *handle)
return rdn_name_rename_do_mod(handle); return rdn_name_rename_do_mod(handle);
case RENAME_MODIFY: 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; handle->status = ret;
goto done; goto done;
@ -300,12 +300,12 @@ done:
return ret; return ret;
} }
static int rename_async_wait_all(struct ldb_async_handle *handle) { static int rename_wait_all(struct ldb_handle *handle) {
int ret; int ret;
while (handle->state != LDB_ASYNC_DONE) { while (handle->state != LDB_ASYNC_DONE) {
ret = rename_async_wait(handle); ret = rename_wait(handle);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
return ret; return ret;
} }
@ -314,12 +314,12 @@ static int rename_async_wait_all(struct ldb_async_handle *handle) {
return handle->status; 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) { if (type == LDB_WAIT_ALL) {
return rename_async_wait_all(handle); return rename_wait_all(handle);
} else { } 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", .name = "rdn_name",
.add = rdn_name_add, .add = rdn_name_add,
.rename = rdn_name_rename, .rename = rdn_name_rename,
.async_wait = rdn_name_async_wait .wait = rdn_name_wait
}; };

View File

@ -43,10 +43,10 @@ struct opaque {
int result; int result;
}; };
struct sort_async_context { struct sort_context {
struct ldb_module *module; struct ldb_module *module;
void *up_context; 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 *attributeName;
char *orderingRule; char *orderingRule;
@ -63,14 +63,14 @@ struct sort_async_context {
int sort_result; 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, 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 sort_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
h = talloc_zero(mem_ctx, struct ldb_async_handle); h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) { if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL; return NULL;
@ -78,7 +78,7 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
h->module = module; h->module = module;
ac = talloc_zero(h, struct sort_async_context); ac = talloc_zero(h, struct sort_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h); 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) 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; struct ldb_message_element *el1, *el2;
if (ac->sort_result != 0) { 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]); 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) { if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error; 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) { if (ares->type == LDB_REPLY_ENTRY) {
ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2); 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_control *control;
struct ldb_server_sort_control **sort_ctrls; struct ldb_server_sort_control **sort_ctrls;
struct ldb_control **saved_controls; struct ldb_control **saved_controls;
struct sort_async_context *ac; struct sort_context *ac;
struct ldb_async_handle *h; struct ldb_handle *h;
int ret; int ret;
/* check if there's a paged request control */ /* 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) { if (!h) {
return LDB_ERR_OPERATIONS_ERROR; 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 *); sort_ctrls = talloc_get_type(control->data, struct ldb_server_sort_control *);
if (!sort_ctrls) { 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 (sort_ctrls[1] != NULL) {
if (control->critical) { 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) if (!ares)
return LDB_ERR_OPERATIONS_ERROR; 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); 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 sort_context *ac;
struct ldb_async_result *ares; struct ldb_reply *ares;
int i, ret; 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->h = ldb_attrib_handler(ac->module->ldb, ac->attributeName);
ac->sort_result = 0; 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); ac, (ldb_qsort_cmp_fn_t)sort_compare);
for (i = 0; i < ac->num_msgs; i++) { 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) { if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status; 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++) { 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) { if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status; 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) { if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR; handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status; return handle->status;
@ -387,18 +387,18 @@ static int server_sort_results(struct ldb_async_handle *handle)
return LDB_SUCCESS; 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; int ret;
if (!handle || !handle->private_data) { if (!handle || !handle->private_data) {
return LDB_ERR_OPERATIONS_ERROR; 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) { if (ret != LDB_SUCCESS) {
handle->status = ret; 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 = { static const struct ldb_module_ops server_sort_ops = {
.name = "server_sort", .name = "server_sort",
.search = server_sort_search, .search = server_sort_search,
.async_wait = server_sort_async_wait, .wait = server_sort_wait,
.init_context = server_sort_init .init_context = server_sort_init
}; };

View File

@ -58,7 +58,7 @@ static int do_compare_msg(struct ldb_message **el1,
return ldb_dn_compare(ldb, (*el1)->dn, (*el2)->dn); return ldb_dn_compare(ldb, (*el1)->dn, (*el2)->dn);
} }
struct async_context { struct search_context {
struct ldb_control **req_ctrls; struct ldb_control **req_ctrls;
int sort; int sort;
@ -73,56 +73,56 @@ struct async_context {
int status; 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); sctx->store = talloc_realloc(sctx, sctx->store, struct ldb_message *, sctx->num_stored + 2);
if (!actx->store) { if (!sctx->store) {
fprintf(stderr, "talloc_realloc failed while storing messages\n"); fprintf(stderr, "talloc_realloc failed while storing messages\n");
return -1; return -1;
} }
actx->store[actx->num_stored] = talloc_steal(actx->store, msg); sctx->store[sctx->num_stored] = talloc_steal(sctx->store, msg);
if (!actx->store[actx->num_stored]) { if (!sctx->store[sctx->num_stored]) {
fprintf(stderr, "talloc_steal failed while storing messages\n"); fprintf(stderr, "talloc_steal failed while storing messages\n");
return -1; return -1;
} }
actx->num_stored++; sctx->num_stored++;
actx->store[actx->num_stored] = NULL; sctx->store[sctx->num_stored] = NULL;
return 0; 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); sctx->refs_store = talloc_realloc(sctx, sctx->refs_store, char *, sctx->refs + 2);
if (!actx->refs_store) { if (!sctx->refs_store) {
fprintf(stderr, "talloc_realloc failed while storing referrals\n"); fprintf(stderr, "talloc_realloc failed while storing referrals\n");
return -1; return -1;
} }
actx->refs_store[actx->refs] = talloc_steal(actx->refs_store, referral); sctx->refs_store[sctx->refs] = talloc_steal(sctx->refs_store, referral);
if (!actx->refs_store[actx->refs]) { if (!sctx->refs_store[sctx->refs]) {
fprintf(stderr, "talloc_steal failed while storing referrals\n"); fprintf(stderr, "talloc_steal failed while storing referrals\n");
return -1; return -1;
} }
actx->refs++; sctx->refs++;
actx->refs_store[actx->refs] = NULL; sctx->refs_store[sctx->refs] = NULL;
return 0; 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; struct ldb_ldif ldif;
actx->entries++; sctx->entries++;
printf("# record %d\n", actx->entries); printf("# record %d\n", sctx->entries);
ldif.changetype = LDB_CHANGETYPE_NONE; ldif.changetype = LDB_CHANGETYPE_NONE;
ldif.msg = msg; ldif.msg = msg;
if (actx->sort) { if (sctx->sort) {
/* /*
* Ensure attributes are always returned in the same * Ensure attributes are always returned in the same
* order. For testing, this makes comparison of old * 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; 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); printf("# Referral\nref: %s\n\n", referral);
return 0; 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; int ret;
switch (ares->type) { switch (ares->type) {
case LDB_REPLY_ENTRY: case LDB_REPLY_ENTRY:
if (actx->sort) { if (sctx->sort) {
ret = store_message(ares->message, actx); ret = store_message(ares->message, sctx);
} else { } else {
ret = display_message(ldb, ares->message, actx); ret = display_message(ldb, ares->message, sctx);
} }
break; break;
case LDB_REPLY_REFERRAL: case LDB_REPLY_REFERRAL:
if (actx->sort) { if (sctx->sort) {
ret = store_referral(ares->referral, actx); ret = store_referral(ares->referral, sctx);
} else { } else {
ret = display_referral(ares->referral, actx); ret = display_referral(ares->referral, sctx);
} }
break; break;
case LDB_REPLY_DONE: case LDB_REPLY_DONE:
if (ares->controls) { if (ares->controls) {
if (handle_controls_reply(ares->controls, actx->req_ctrls) == 1) if (handle_controls_reply(ares->controls, sctx->req_ctrls) == 1)
actx->pending = 1; sctx->pending = 1;
} }
ret = 0; ret = 0;
break; break;
@ -182,7 +182,7 @@ static int search_callback(struct ldb_context *ldb, void *context, struct ldb_as
if (talloc_free(ares) == -1) { if (talloc_free(ares) == -1) {
fprintf(stderr, "talloc_free failed\n"); fprintf(stderr, "talloc_free failed\n");
actx->pending = 0; sctx->pending = 0;
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
@ -200,22 +200,22 @@ static int do_search(struct ldb_context *ldb,
const char * const *attrs) const char * const *attrs)
{ {
struct ldb_request *req; struct ldb_request *req;
struct async_context *actx; struct search_context *sctx;
int ret; int ret;
req = talloc(ldb, struct ldb_request); req = talloc(ldb, struct ldb_request);
if (!req) return -1; if (!req) return -1;
actx = talloc(req, struct async_context); sctx = talloc(req, struct search_context);
if (!actx) return -1; if (!sctx) return -1;
actx->sort = options->sorted; sctx->sort = options->sorted;
actx->num_stored = 0; sctx->num_stored = 0;
actx->store = NULL; sctx->store = NULL;
actx->req_ctrls = parse_controls(ldb, options->controls); sctx->req_ctrls = parse_controls(ldb, options->controls);
if (options->controls != NULL && actx->req_ctrls== NULL) return -1; if (options->controls != NULL && sctx->req_ctrls== NULL) return -1;
actx->entries = 0; sctx->entries = 0;
actx->refs = 0; sctx->refs = 0;
req->operation = LDB_SEARCH; req->operation = LDB_SEARCH;
req->op.search.base = basedn; 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); req->op.search.tree = ldb_parse_tree(ldb, expression);
if (req->op.search.tree == NULL) return -1; if (req->op.search.tree == NULL) return -1;
req->op.search.attrs = attrs; req->op.search.attrs = attrs;
req->controls = actx->req_ctrls; req->controls = sctx->req_ctrls;
req->async.context = actx; req->async.context = sctx;
req->async.callback = &search_callback; req->async.callback = &search_callback;
ldb_set_timeout(ldb, req, 0); /* TODO: make this settable by command line */ ldb_set_timeout(ldb, req, 0); /* TODO: make this settable by command line */
again: again:
actx->pending = 0; sctx->pending = 0;
ret = ldb_request(ldb, req); ret = ldb_request(ldb, req);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
@ -237,19 +237,19 @@ again:
return -1; 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) { if (ret != LDB_SUCCESS) {
printf("search error - %s\n", ldb_errstring(ldb)); printf("search error - %s\n", ldb_errstring(ldb));
return -1; return -1;
} }
if (actx->pending) if (sctx->pending)
goto again; goto again;
if (actx->sort && actx->num_stored != 0) { if (sctx->sort && sctx->num_stored != 0) {
int i; 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); ldb, (ldb_qsort_cmp_fn_t)do_compare_msg);
if (ret != 0) { if (ret != 0) {
@ -257,17 +257,17 @@ again:
exit(1); exit(1);
} }
for (i = 0; i < actx->num_stored; i++) { for (i = 0; i < sctx->num_stored; i++) {
display_message(ldb, actx->store[i], actx); display_message(ldb, sctx->store[i], sctx);
} }
for (i = 0; i < actx->refs; i++) { for (i = 0; i < sctx->refs; i++) {
display_referral(actx->refs_store[i], actx); display_referral(sctx->refs_store[i], sctx);
} }
} }
printf("# returned %d records\n# %d entries\n# %d referrals\n", 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); talloc_free(req);

View File

@ -102,7 +102,7 @@ struct test_rootDSE {
const char *schemadn; const char *schemadn;
}; };
struct test_schema_async_ctx { struct test_schema_ctx {
struct ldb_paged_control *ctrl; struct ldb_paged_control *ctrl;
uint32_t count; uint32_t count;
BOOL pending; BOOL pending;
@ -143,9 +143,9 @@ static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro
return True; return True;
} }
static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares) static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{ {
struct test_schema_async_ctx *actx = talloc_get_type(context, struct test_schema_async_ctx); struct test_schema_ctx *actx = talloc_get_type(context, struct test_schema_ctx);
int ret = LDB_SUCCESS; int ret = LDB_SUCCESS;
switch (ares->type) { switch (ares->type) {
@ -208,10 +208,10 @@ static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE
struct ldb_paged_control *control; struct ldb_paged_control *control;
struct ldb_request *req; struct ldb_request *req;
int ret; int ret;
struct test_schema_async_ctx *actx; struct test_schema_ctx *actx;
req = talloc(ldb, struct ldb_request); req = talloc(ldb, struct ldb_request);
actx = talloc(req, struct test_schema_async_ctx); actx = talloc(req, struct test_schema_ctx);
ctrl = talloc_array(req, struct ldb_control *, 2); ctrl = talloc_array(req, struct ldb_control *, 2);
ctrl[0] = talloc(ctrl, struct ldb_control); ctrl[0] = talloc(ctrl, struct ldb_control);
@ -248,7 +248,7 @@ again:
return False; return False;
} }
ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL); ret = ldb_wait(req->async.handle, LDB_WAIT_ALL);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
d_printf("search error - %s\n", ldb_errstring(ldb)); d_printf("search error - %s\n", ldb_errstring(ldb));
return False; return False;