summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules/paged_results.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-05-29 01:30:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:41 -0500
commit3a4d7eb2c08a06fac89c34d132f1c32751ce7ad5 (patch)
tree7d34281bba70aaa79d7527b823f00f625836dc3a /source4/lib/ldb/modules/paged_results.c
parent0bd3636a1249dd55f7595c06892e2db65af18bfc (diff)
downloadsamba-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/paged_results.c')
-rw-r--r--source4/lib/ldb/modules/paged_results.c32
1 files changed, 20 insertions, 12 deletions
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