diff options
author | Simo Sorce <idra@samba.org> | 2006-05-29 01:30:02 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:08:41 -0500 |
commit | 3a4d7eb2c08a06fac89c34d132f1c32751ce7ad5 (patch) | |
tree | 7d34281bba70aaa79d7527b823f00f625836dc3a /source4/lib/ldb/modules | |
parent | 0bd3636a1249dd55f7595c06892e2db65af18bfc (diff) | |
download | samba-3a4d7eb2c08a06fac89c34d132f1c32751ce7ad5.tar.gz samba-3a4d7eb2c08a06fac89c34d132f1c32751ce7ad5.tar.bz2 samba-3a4d7eb2c08a06fac89c34d132f1c32751ce7ad5.zip |
r15927: Optimize ldb module traverse while keeping the API intact.
I was sick of jumping inot each module for each request,
even the ones not handle by that module.
(This used to be commit 7d65105e885a28584e8555453b90232c43a92bf7)
Diffstat (limited to 'source4/lib/ldb/modules')
-rw-r--r-- | source4/lib/ldb/modules/asq.c | 18 | ||||
-rw-r--r-- | source4/lib/ldb/modules/operational.c | 26 | ||||
-rw-r--r-- | source4/lib/ldb/modules/paged_results.c | 32 | ||||
-rw-r--r-- | source4/lib/ldb/modules/rdn_name.c | 10 | ||||
-rw-r--r-- | source4/lib/ldb/modules/skel.c | 28 | ||||
-rw-r--r-- | source4/lib/ldb/modules/sort.c | 14 |
6 files changed, 61 insertions, 67 deletions
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index de5a0e34b7..3a29d3f266 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -77,7 +77,7 @@ static int build_response(struct ldb_result *res, int result) } /* search */ -static int asq_search(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) +static int asq_search_sync(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) { struct ldb_asq_control *asq_ctrl; struct ldb_request *base_req; @@ -352,14 +352,22 @@ error: return LDB_ERR_OPERATIONS_ERROR; } -static int asq_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) +static int asq_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_control *control; struct ldb_asq_control *asq_ctrl; struct asq_async_context *ac; struct ldb_async_handle *h; char **base_attrs; int ret; + /* check if there's a paged request control */ + control = get_control_from_list(req->controls, LDB_CONTROL_ASQ_OID); + if (control == NULL) { + /* not found go on */ + return ldb_next_request(module, req); + } + req->async.handle = NULL; if (!req->async.callback || !req->async.context) { @@ -590,11 +598,8 @@ static int asq(struct ldb_module *module, struct ldb_request *req) switch (req->operation) { case LDB_REQ_SEARCH: - return asq_search(module, control, req); + return asq_search_sync(module, control, req); - case LDB_ASYNC_SEARCH: - return asq_search_async(module, control, req); - default: return LDB_ERR_PROTOCOL_ERROR; @@ -622,6 +627,7 @@ static int asq_init(struct ldb_module *module) static const struct ldb_module_ops asq_ops = { .name = "asq", + .search = asq_search, .request = asq, .async_wait = asq_async_wait, .init_context = asq_init diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index d796e93e54..b47adf0652 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -295,7 +295,7 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ /* hook add record ops */ -static int operational_add(struct ldb_module *module, struct ldb_request *req) +static int operational_add_sync(struct ldb_module *module, struct ldb_request *req) { const struct ldb_message *msg = req->op.add.message; time_t t = time(NULL); @@ -341,7 +341,7 @@ static int operational_add(struct ldb_module *module, struct ldb_request *req) /* hook modify record ops */ -static int operational_modify(struct ldb_module *module, struct ldb_request *req) +static int operational_modify_sync(struct ldb_module *module, struct ldb_request *req) { const struct ldb_message *msg = req->op.mod.message; time_t t = time(NULL); @@ -421,7 +421,7 @@ error: return LDB_ERR_OPERATIONS_ERROR; } -static int operational_search_async(struct ldb_module *module, struct ldb_request *req) +static int operational_search(struct ldb_module *module, struct ldb_request *req) { struct operational_async_context *ac; struct ldb_request *down_req; @@ -506,7 +506,7 @@ static int operational_search_async(struct ldb_module *module, struct ldb_reques /* hook add record ops */ -static int operational_add_async(struct ldb_module *module, struct ldb_request *req) +static int operational_add(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *down_req; struct ldb_message *msg; @@ -560,7 +560,7 @@ static int operational_add_async(struct ldb_module *module, struct ldb_request * /* hook modify record ops */ -static int operational_modify_async(struct ldb_module *module, struct ldb_request *req) +static int operational_modify(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *down_req; struct ldb_message *msg; @@ -617,19 +617,10 @@ static int operational_request(struct ldb_module *module, struct ldb_request *re return operational_search_bytree(module, req); case LDB_REQ_ADD: - return operational_add(module, req); + return operational_add_sync(module, req); case LDB_REQ_MODIFY: - return operational_modify(module, req); - - case LDB_ASYNC_SEARCH: - return operational_search_async(module, req); - - case LDB_ASYNC_ADD: - return operational_add_async(module, req); - - case LDB_ASYNC_MODIFY: - return operational_modify_async(module, req); + return operational_modify_sync(module, req); default: return ldb_next_request(module, req); @@ -650,6 +641,9 @@ static int operational_init(struct ldb_module *ctx) static const struct ldb_module_ops operational_ops = { .name = "operational", + .search = operational_search, + .add = operational_add, + .modify = operational_modify, .request = operational_request, .init_context = operational_init }; diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index 1b002716a5..fab1ca5ac1 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -123,7 +123,7 @@ static struct results_store *new_store(struct private_data *priv) } /* search */ -static int paged_search(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) +static int paged_search_sync(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) { struct private_data *private_data = talloc_get_type(module->private_data, struct private_data); struct results_store *current = NULL; @@ -364,15 +364,25 @@ error: return LDB_ERR_OPERATIONS_ERROR; } -static int paged_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) +static int paged_search(struct ldb_module *module, struct ldb_request *req) { - struct private_data *private_data = talloc_get_type(module->private_data, struct private_data); + struct ldb_control *control; + struct private_data *private_data; struct ldb_paged_control *paged_ctrl; struct ldb_control **saved_controls; struct paged_async_context *ac; struct ldb_async_handle *h; int ret; + /* check if there's a paged request control */ + control = get_control_from_list(req->controls, LDB_CONTROL_PAGED_RESULTS_OID); + if (control == NULL) { + /* not found go on */ + return ldb_next_request(module, req); + } + + private_data = talloc_get_type(module->private_data, struct private_data); + req->async.handle = NULL; if (!req->async.callback || !req->async.context) { @@ -463,7 +473,7 @@ static int paged_search_async(struct ldb_module *module, struct ldb_control *con } -static int paged_async_results(struct ldb_async_handle *handle) +static int paged_results(struct ldb_async_handle *handle) { struct paged_async_context *ac; struct ldb_paged_control *paged; @@ -590,7 +600,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait if (ac->store->req->async.handle->state == LDB_ASYNC_DONE) { /* if lower level is finished we do not need to call it anymore */ /* return all we have until size == 0 or we empty storage */ - ret = paged_async_results(handle); + ret = paged_results(handle); /* we are done, if num_entries is zero free the storage * as that mean we delivered the last batch */ @@ -611,7 +621,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait } } - ret = paged_async_results(handle); + ret = paged_results(handle); /* we are done, if num_entries is zero free the storage * as that mean we delivered the last batch */ @@ -634,7 +644,7 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait if (ac->store->num_entries >= ac->size || ac->store->req->async.handle->state == LDB_ASYNC_DONE) { - ret = paged_async_results(handle); + ret = paged_results(handle); /* we are done, if num_entries is zero free the storage * as that mean we delivered the last batch */ @@ -660,10 +670,7 @@ static int paged_request(struct ldb_module *module, struct ldb_request *req) switch (req->operation) { case LDB_REQ_SEARCH: - return paged_search(module, control, req); - - case LDB_ASYNC_SEARCH: - return paged_search_async(module, control, req); + return paged_search_sync(module, control, req); default: return LDB_ERR_PROTOCOL_ERROR; @@ -707,7 +714,8 @@ static int paged_request_init(struct ldb_module *module) } static const struct ldb_module_ops paged_ops = { - .name = "paged_results", + .name = "paged_results", + .search = paged_search, .request = paged_request, .async_wait = paged_async_wait, .init_context = paged_request_init diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 7ce6c29691..2004002e38 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -310,7 +310,7 @@ static int rdn_name_rename_do_mod(struct ldb_async_handle *h) { ac->step = RENAME_MODIFY; /* do the mod call */ - return ldb_next_request(h->module, ac->mod_req); + return ldb_request(h->module->ldb, ac->mod_req); } static int rename_async_wait(struct ldb_async_handle *handle) @@ -409,12 +409,6 @@ static int rdn_name_request(struct ldb_module *module, struct ldb_request *req) case LDB_REQ_ADD: return rdn_name_add_sync(module, req); - case LDB_ASYNC_ADD: - return rdn_name_add(module, req); - - case LDB_ASYNC_RENAME: - return rdn_name_rename(module, req); - default: return ldb_next_request(module, req); @@ -423,6 +417,8 @@ static int rdn_name_request(struct ldb_module *module, struct ldb_request *req) static const struct ldb_module_ops rdn_name_ops = { .name = "rdn_name", + .add = rdn_name_add, + .rename = rdn_name_rename, .request = rdn_name_request, .async_wait = rdn_name_async_wait }; diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c index 2f3c2e8b57..2adef580b1 100644 --- a/source4/lib/ldb/modules/skel.c +++ b/source4/lib/ldb/modules/skel.c @@ -97,28 +97,7 @@ static int skel_destructor(struct ldb_module *ctx) static int skel_request(struct ldb_module *module, struct ldb_request *req) { - switch (req->operation) { - - case LDB_REQ_SEARCH: - return skel_search(module, req); - - case LDB_REQ_ADD: - return skel_add(module, req); - - case LDB_REQ_MODIFY: - return skel_modify(module, req); - - case LDB_REQ_DELETE: - return skel_delete(module, req); - - case LDB_REQ_RENAME: - return skel_rename(module, - req); - - default: - return ldb_next_request(module, req); - - } + return ldb_next_request(module, req); } static int skel_init(struct ldb_module *ctx) @@ -141,6 +120,11 @@ static int skel_init(struct ldb_module *ctx) static const struct ldb_module_ops skel_ops = { .name = "skel", .init_context = skel_init, + .search = skel_search, + .add = skel_add, + .modify = skel_modify, + .del = skel_delete, + .rename = skel_rename, .request = skel_request, .start_transaction = skel_start_trans, .end_transaction = skel_end_trans, diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 3e1bbe92bd..9f03100dd0 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -340,14 +340,22 @@ error: return LDB_ERR_OPERATIONS_ERROR; } -static int server_sort_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req) +static int server_sort_search_async(struct ldb_module *module, struct ldb_request *req) { + struct ldb_control *control; struct ldb_server_sort_control **sort_ctrls; struct ldb_control **saved_controls; struct sort_async_context *ac; struct ldb_async_handle *h; int ret; + /* check if there's a paged request control */ + control = get_control_from_list(req->controls, LDB_CONTROL_SERVER_SORT_OID); + if (control == NULL) { + /* not found go on */ + return ldb_next_request(module, req); + } + req->async.handle = NULL; if (!req->async.callback || !req->async.context) { @@ -543,9 +551,6 @@ static int server_sort(struct ldb_module *module, struct ldb_request *req) case LDB_REQ_SEARCH: return server_sort_search(module, control, req); - case LDB_ASYNC_SEARCH: - return server_sort_search_async(module, control, req); - default: return LDB_ERR_PROTOCOL_ERROR; @@ -579,6 +584,7 @@ static int server_sort_init(struct ldb_module *module) static const struct ldb_module_ops server_sort_ops = { .name = "server_sort", + .search = server_sort_search_async, .request = server_sort, .async_wait = server_sort_async_wait, .init_context = server_sort_init |