1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

ldb_tdb: Add lock_read and unlock_read to key value ops

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Garming Sam 2017-01-10 23:19:55 +13:00 committed by Andrew Bartlett
parent 448101a3fd
commit e21a476c27
3 changed files with 31 additions and 15 deletions

View File

@ -711,17 +711,17 @@ int ltdb_search(struct ltdb_context *ctx)
ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_lock_read(module) != 0) {
if (ltdb->kv_ops->lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
if (ltdb_cache_load(module) != 0) {
ltdb_unlock_read(module);
ltdb->kv_ops->unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
ltdb_unlock_read(module);
ltdb->kv_ops->unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
@ -768,7 +768,7 @@ int ltdb_search(struct ltdb_context *ctx)
*/
ret = ltdb_search_and_return_base(ltdb, ctx);
ltdb_unlock_read(module);
ltdb->kv_ops->unlock_read(module);
return ret;
@ -830,7 +830,7 @@ int ltdb_search(struct ltdb_context *ctx)
* full search or we may return
* duplicate entries
*/
ltdb_unlock_read(module);
ltdb->kv_ops->unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
ret = ltdb_search_full(ctx);
@ -840,7 +840,7 @@ int ltdb_search(struct ltdb_context *ctx)
}
}
ltdb_unlock_read(module);
ltdb->kv_ops->unlock_read(module);
return ret;
}

View File

@ -94,7 +94,7 @@ int ltdb_err_map(enum TDB_ERROR tdb_code)
/*
lock the database for read - use by ltdb_search and ltdb_sequence_number
*/
int ltdb_lock_read(struct ldb_module *module)
static int ltdb_lock_read(struct ldb_module *module)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
@ -124,7 +124,7 @@ int ltdb_lock_read(struct ldb_module *module)
/*
unlock the database after a ltdb_lock_read()
*/
int ltdb_unlock_read(struct ldb_module *module)
static int ltdb_unlock_read(struct ldb_module *module)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
@ -1529,6 +1529,8 @@ static int ltdb_sequence_number(struct ltdb_context *ctx,
struct ldb_context *ldb;
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TALLOC_CTX *tmp_ctx = NULL;
struct ldb_seqnum_request *seq;
struct ldb_seqnum_result *res;
@ -1547,7 +1549,7 @@ static int ltdb_sequence_number(struct ltdb_context *ctx,
ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_lock_read(module) != 0) {
if (ltdb->kv_ops->lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
@ -1609,7 +1611,8 @@ static int ltdb_sequence_number(struct ltdb_context *ctx,
done:
talloc_free(tmp_ctx);
ltdb_unlock_read(module);
ltdb->kv_ops->unlock_read(module);
return ret;
}
@ -1872,6 +1875,21 @@ static int ltdb_init_rootdse(struct ldb_module *module)
return LDB_SUCCESS;
}
static int generic_lock_read(struct ldb_module *module)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
return ltdb->kv_ops->lock_read(module);
}
static int generic_unlock_read(struct ldb_module *module)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
return ltdb->kv_ops->unlock_read(module);
}
static const struct ldb_module_ops ltdb_ops = {
.name = "tdb",
.init_context = ltdb_init_rootdse,
@ -1885,8 +1903,8 @@ static const struct ldb_module_ops ltdb_ops = {
.end_transaction = ltdb_end_trans,
.prepare_commit = ltdb_prepare_commit,
.del_transaction = ltdb_del_trans,
.read_lock = ltdb_lock_read,
.read_unlock = ltdb_unlock_read,
.read_lock = generic_lock_read,
.read_unlock = generic_unlock_read,
};
/*
@ -1905,7 +1923,6 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
* We hold locks, so we must use a private event context
* on each returned handle
*/
ldb_set_require_private_event_context(ldb);
/* parse the url */

View File

@ -165,8 +165,6 @@ int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
int ltdb_search(struct ltdb_context *ctx);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
int ltdb_lock_read(struct ldb_module *module);
int ltdb_unlock_read(struct ldb_module *module);
/*
* Determine if this key could hold a record. We allow the new GUID
* index, the old DN index and a possible future ID=
@ -185,6 +183,7 @@ int ltdb_idx_to_key(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
const struct ldb_val *idx_val,
TDB_DATA *key);
TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
int ltdb_delete_noindex(struct ldb_module *module,