summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
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/common
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/common')
-rw-r--r--source4/lib/ldb/common/ldb.c44
-rw-r--r--source4/lib/ldb/common/ldb_modules.c23
2 files changed, 55 insertions, 12 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 3d5f816fe8..f348001456 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -280,7 +280,8 @@ static int ldb_op_finish(struct ldb_context *ldb, int status)
*/
int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
{
- int status, started_transaction=0;
+ struct ldb_module *module;
+ int ret, started_transaction=0;
ldb_reset_err_string(ldb);
@@ -288,28 +289,52 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
req->op.search.res = NULL;
}
- /* start a transaction if not async and not search */
+ /* start a transaction if SYNC and not search */
if ((!ldb->transaction_active) &&
(req->operation == LDB_REQ_ADD ||
req->operation == LDB_REQ_MODIFY ||
req->operation == LDB_REQ_DELETE ||
req->operation == LDB_REQ_RENAME)) {
- status = ldb_transaction_start(ldb);
- if (status != LDB_SUCCESS) {
- talloc_free(req);
- return status;
+ ret = ldb_transaction_start(ldb);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
started_transaction = 1;
}
/* call the first module in the chain */
- status = ldb->modules->ops->request(ldb->modules, req);
+ switch (req->operation) {
+ case LDB_ASYNC_SEARCH:
+ FIRST_OP(ldb, search);
+ ret = module->ops->search(module, req);
+ break;
+ case LDB_ASYNC_ADD:
+ FIRST_OP(ldb, add);
+ ret = module->ops->add(module, req);
+ break;
+ case LDB_ASYNC_MODIFY:
+ FIRST_OP(ldb, modify);
+ ret = module->ops->modify(module, req);
+ break;
+ case LDB_ASYNC_DELETE:
+ FIRST_OP(ldb, del);
+ ret = module->ops->del(module, req);
+ break;
+ case LDB_ASYNC_RENAME:
+ FIRST_OP(ldb, rename);
+ ret = module->ops->rename(module, req);
+ break;
+ default:
+ FIRST_OP(ldb, request);
+ ret = module->ops->request(module, req);
+ break;
+ }
if (started_transaction) {
- return ldb_op_finish(ldb, status);
+ return ldb_op_finish(ldb, ret);
}
- return status;
+ return ret;
}
/*
@@ -453,7 +478,6 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque
}
ret = ldb_request(ldb, req);
-
if (ret == LDB_SUCCESS) {
ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
}
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index bc27d1ed1b..4ce404d096 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -347,10 +347,29 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
/*
helper functions to call the next module in chain
*/
+
int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
{
- FIND_OP(module, request);
- return module->ops->request(module, request);
+ switch (request->operation) {
+ case LDB_ASYNC_SEARCH:
+ FIND_OP(module, search);
+ return module->ops->search(module, request);
+ case LDB_ASYNC_ADD:
+ FIND_OP(module, add);
+ return module->ops->add(module, request);
+ case LDB_ASYNC_MODIFY:
+ FIND_OP(module, modify);
+ return module->ops->modify(module, request);
+ case LDB_ASYNC_DELETE:
+ FIND_OP(module, del);
+ return module->ops->del(module, request);
+ case LDB_ASYNC_RENAME:
+ FIND_OP(module, rename);
+ return module->ops->rename(module, request);
+ default:
+ FIND_OP(module, request);
+ return module->ops->request(module, request);
+ }
}
int ldb_next_init(struct ldb_module *module)