summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-06-04 05:28:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:52 -0500
commitca5accf224dc3ef998235603797b519866b57b1c (patch)
tree3d2790afbc47076c2b12611d5c1e5b20683b36c5 /source4/lib/ldb/modules
parentb31c685ec293ef65bc33a474fc5a1d83545d4749 (diff)
downloadsamba-ca5accf224dc3ef998235603797b519866b57b1c.tar.gz
samba-ca5accf224dc3ef998235603797b519866b57b1c.tar.bz2
samba-ca5accf224dc3ef998235603797b519866b57b1c.zip
r16036: Add a couple of new functions to corretly deal with timeouts.
Check timeouts are correctly verified. Some minor fixed and removal of unused code. (This used to be commit b52e5d6a0cb1a32e62759eaa49ce3e4cc804cc92)
Diffstat (limited to 'source4/lib/ldb/modules')
-rw-r--r--source4/lib/ldb/modules/asq.c26
-rw-r--r--source4/lib/ldb/modules/objectclass.c6
-rw-r--r--source4/lib/ldb/modules/operational.c8
-rw-r--r--source4/lib/ldb/modules/paged_results.c9
-rw-r--r--source4/lib/ldb/modules/rdn_name.c2
-rw-r--r--source4/lib/ldb/modules/sort.c38
6 files changed, 31 insertions, 58 deletions
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index 396a2346df..75ef4a487e 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -48,7 +48,6 @@ struct asq_async_context {
struct ldb_module *module;
void *up_context;
int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
- int timeout;
const char * const *req_attrs;
char *req_attribute;
@@ -66,8 +65,7 @@ struct asq_async_context {
static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout)
+ int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
{
struct asq_async_context *ac;
struct ldb_async_handle *h;
@@ -95,7 +93,6 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
ac->module = module;
ac->up_context = context;
ac->up_callback = callback;
- ac->timeout = timeout;
return h;
}
@@ -233,7 +230,7 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_PROTOCOL_ERROR;
}
- h = init_handle(req, module, req->async.context, req->async.callback, req->async.timeout);
+ h = init_handle(req, module, req->async.context, req->async.callback);
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -271,7 +268,7 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
ac->base_req->async.context = ac;
ac->base_req->async.callback = asq_base_callback;
- ac->base_req->async.timeout = req->async.timeout;
+ ldb_set_timeout_from_prev_req(module->ldb, req, ac->base_req);
ac->step = ASQ_SEARCH_BASE;
@@ -324,7 +321,7 @@ static int asq_async_requests(struct ldb_async_handle *handle) {
ac->reqs[i]->async.context = ac;
ac->reqs[i]->async.callback = asq_reqs_callback;
- ac->reqs[i]->async.timeout = ac->base_req->async.timeout;
+ ldb_set_timeout_from_prev_req(ac->module->ldb, ac->base_req, ac->reqs[i]);
}
ac->step = ASQ_SEARCH_MULTI;
@@ -436,14 +433,19 @@ static int asq_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_t
static int asq_init(struct ldb_module *module)
{
- struct ldb_request request;
+ struct ldb_request *req;
int ret;
- request.operation = LDB_REQ_REGISTER;
- request.op.reg.oid = LDB_CONTROL_ASQ_OID;
- request.controls = NULL;
+ req = talloc_zero(module, struct ldb_request);
+ if (req == NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, "asq: Out of memory!\n");
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_REQ_REGISTER;
+ req->op.reg.oid = LDB_CONTROL_ASQ_OID;
- ret = ldb_request(module->ldb, &request);
+ ret = ldb_request(module->ldb, req);
if (ret != LDB_SUCCESS) {
ldb_debug(module->ldb, LDB_DEBUG_ERROR, "asq: Unable to register control with rootdse!\n");
return LDB_ERR_OTHER;
diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c
index 4423f82aed..6c50ba19c8 100644
--- a/source4/lib/ldb/modules/objectclass.c
+++ b/source4/lib/ldb/modules/objectclass.c
@@ -124,6 +124,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req)
ac->down_req->async.context = NULL;
ac->down_req->async.callback = NULL;
+ ldb_set_timeout_from_prev_req(module->ldb, req, ac->down_req);
ac->step = OC_DO_REQ;
@@ -171,6 +172,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
ac->down_req->async.context = NULL;
ac->down_req->async.callback = NULL;
+ ldb_set_timeout_from_prev_req(module->ldb, req, ac->down_req);
ac->step = OC_DO_REQ;
@@ -230,7 +232,7 @@ static int objectclass_search_self(struct ldb_async_handle *h) {
ac->search_req->controls = NULL;
ac->search_req->async.context = ac;
ac->search_req->async.callback = get_self_callback;
- ac->search_req->async.timeout = ac->orig_req->async.timeout;
+ ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->search_req);
ac->step = OC_SEARCH_SELF;
@@ -270,7 +272,7 @@ static int objectclass_do_mod(struct ldb_async_handle *h) {
ac->mod_req->controls = NULL;
ac->mod_req->async.context = ac;
ac->mod_req->async.callback = NULL;
- ac->mod_req->async.timeout = ac->orig_req->async.timeout;
+ ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->mod_req);
/* use a new message structure */
ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req);
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index 4b1daba30f..b404e94580 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -231,7 +231,6 @@ struct operational_async_context {
struct ldb_module *module;
void *up_context;
int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
- int timeout;
const char * const *attrs;
};
@@ -279,7 +278,6 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
ac->module = module;
ac->up_context = req->async.context;
ac->up_callback = req->async.callback;
- ac->timeout = req->async.timeout;
ac->attrs = req->op.search.attrs;
down_req = talloc_zero(req, struct ldb_request);
@@ -329,7 +327,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
down_req->async.context = ac;
down_req->async.callback = operational_async_callback;
- down_req->async.timeout = req->async.timeout;
+ ldb_set_timeout_from_prev_req(module->ldb, req, down_req);
/* perform the search */
ret = ldb_next_request(module, down_req);
@@ -385,6 +383,8 @@ static int operational_add(struct ldb_module *module, struct ldb_request *req)
}
}
+ ldb_set_timeout_from_prev_req(module->ldb, req, down_req);
+
/* go on with the call chain */
ret = ldb_next_request(module, down_req);
@@ -436,6 +436,8 @@ static int operational_modify(struct ldb_module *module, struct ldb_request *req
return -1;
}
+ ldb_set_timeout_from_prev_req(module->ldb, req, down_req);
+
/* go on with the call chain */
ret = ldb_next_request(module, down_req);
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index 6d864375c6..bdfaea6d51 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -126,7 +126,6 @@ struct paged_async_context {
struct ldb_module *module;
void *up_context;
int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
- int timeout;
int size;
@@ -135,8 +134,7 @@ struct paged_async_context {
static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout)
+ int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
{
struct paged_async_context *ac;
struct ldb_async_handle *h;
@@ -164,7 +162,6 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
ac->module = module;
ac->up_context = context;
ac->up_callback = callback;
- ac->timeout = timeout;
return h;
}
@@ -267,7 +264,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_PROTOCOL_ERROR;
}
- h = init_handle(req, module, req->async.context, req->async.callback, req->async.timeout);
+ h = init_handle(req, module, req->async.context, req->async.callback);
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -304,7 +301,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
ac->store->req->async.context = ac;
ac->store->req->async.callback = paged_search_async_callback;
- ac->store->req->async.timeout = req->async.timeout;
+ ldb_set_timeout_from_prev_req(module->ldb, req, ac->store->req);
ret = ldb_next_request(module, ac->store->req);
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index d6eb0ef13e..7aedc260ad 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -226,7 +226,7 @@ static int rdn_name_rename_do_mod(struct ldb_async_handle *h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac->mod_req->async.timeout = ac->orig_req->async.timeout;
+ ldb_set_timeout_from_prev_req(h->module->ldb, ac->orig_req, ac->mod_req);
ac->step = RENAME_MODIFY;
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 2f9d7dfc96..23f4f36478 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -47,7 +47,6 @@ struct sort_async_context {
struct ldb_module *module;
void *up_context;
int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
- int timeout;
char *attributeName;
char *orderingRule;
@@ -66,8 +65,7 @@ struct sort_async_context {
static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout)
+ int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
{
struct sort_async_context *ac;
struct ldb_async_handle *h;
@@ -95,7 +93,6 @@ static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *mo
ac->module = module;
ac->up_context = context;
ac->up_callback = callback;
- ac->timeout = timeout;
return h;
}
@@ -144,33 +141,6 @@ static int build_response(void *mem_ctx, struct ldb_control ***ctrls, int result
static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, void *opaque)
{
- struct opaque *data = (struct opaque *)opaque;
- struct ldb_message_element *el1, *el2;
-
- if (data->result != 0) {
- /* an error occurred previously,
- * let's exit the sorting by returning always 0 */
- return 0;
- }
-
- el1 = ldb_msg_find_element(*msg1, data->attribute);
- el2 = ldb_msg_find_element(*msg2, data->attribute);
-
- if (!el1 || !el2) {
- /* the attribute was not found return and
- * set an error */
- data->result = 53;
- return 0;
- }
-
- if (data->reverse)
- return data->h->comparison_fn(data->ldb, data, &el2->values[0], &el1->values[0]);
-
- return data->h->comparison_fn(data->ldb, data, &el1->values[0], &el2->values[0]);
-}
-
-static int sort_compare_async(struct ldb_message **msg1, struct ldb_message **msg2, void *opaque)
-{
struct sort_async_context *ac = talloc_get_type(opaque, struct sort_async_context);
struct ldb_message_element *el1, *el2;
@@ -279,7 +249,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
return LDB_ERR_OPERATIONS_ERROR;
}
- h = init_handle(req, module, req->async.context, req->async.callback, req->async.timeout);
+ h = init_handle(req, module, req->async.context, req->async.callback);
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -342,7 +312,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
ac->req->async.context = ac;
ac->req->async.callback = server_sort_search_callback;
- ac->req->async.timeout = req->async.timeout;
+ ldb_set_timeout_from_prev_req(module->ldb, req, ac->req);
req->async.handle = h;
@@ -362,7 +332,7 @@ static int server_sort_results(struct ldb_async_handle *handle)
ldb_qsort(ac->msgs, ac->num_msgs,
sizeof(struct ldb_message *),
- ac, (ldb_qsort_cmp_fn_t)sort_compare_async);
+ ac, (ldb_qsort_cmp_fn_t)sort_compare);
for (i = 0; i < ac->num_msgs; i++) {
ares = talloc_zero(ac, struct ldb_async_result);