From: Garming Sam Date: Tue, 10 Jan 2017 07:43:38 +0000 (+1300) Subject: ldb_tdb: Use key value ops for fetch command X-Git-Tag: talloc-2.1.12~250 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9f2ff275b69bcd13ae236ae07dee8bce0a4e4a2;p=thirdparty%2Fsamba.git ldb_tdb: Use key value ops for fetch command Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c index 58cb36d1f33..4332036790b 100644 --- a/lib/ldb/ldb_tdb/ldb_search.c +++ b/lib/ldb/ldb_tdb/ldb_search.c @@ -252,9 +252,9 @@ int ltdb_search_key(struct ldb_module *module, struct ltdb_private *ltdb, msg->num_elements = 0; msg->elements = NULL; - ret = tdb_parse_record(ltdb->tdb, tdb_key, - ltdb_parse_data_unpack, &ctx); - + ret = ltdb->kv_ops->fetch_and_parse(ltdb, tdb_key, + ltdb_parse_data_unpack, &ctx); + if (ret == -1) { ret = ltdb->kv_ops->error(ltdb); if (ret == LDB_SUCCESS) { diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 6593dc2ee93..f02ad5b53b1 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -1714,6 +1714,14 @@ static void ltdb_handle_extended(struct ltdb_context *ctx) ltdb_request_extended_done(ctx, ext, ret); } +static int ltdb_tdb_parse_record(struct ltdb_private *ltdb, TDB_DATA key, + int (*parser)(TDB_DATA key, TDB_DATA data, + void *private_data), + void *ctx) +{ + return tdb_parse_record(ltdb->tdb, key, parser, ctx); +} + static const char * ltdb_tdb_name(struct ltdb_private *ltdb) { return tdb_name(ltdb->tdb); @@ -1731,6 +1739,7 @@ static bool ltdb_tdb_changed(struct ltdb_private *ltdb) static const struct kv_db_ops key_value_ops = { .store = ltdb_tdb_store, .delete = ltdb_tdb_delete, + .fetch_and_parse = ltdb_tdb_parse_record, .lock_read = ltdb_lock_read, .unlock_read = ltdb_unlock_read, .begin_write = ltdb_tdb_transaction_start, diff --git a/lib/ldb/ldb_tdb/ldb_tdb.h b/lib/ldb/ldb_tdb/ldb_tdb.h index a40bbad9699..ce8f19c2265 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/lib/ldb/ldb_tdb/ldb_tdb.h @@ -8,6 +8,10 @@ struct ltdb_private; struct kv_db_ops { int (*store)(struct ltdb_private *ltdb, TDB_DATA key, TDB_DATA data, int flags); int (*delete)(struct ltdb_private *ltdb, TDB_DATA key); + int (*fetch_and_parse)(struct ltdb_private *ltdb, TDB_DATA key, + int (*parser)(TDB_DATA key, TDB_DATA data, + void *private_data), + void *ctx); int (*lock_read)(struct ldb_module *); int (*unlock_read)(struct ldb_module *); int (*begin_write)(struct ltdb_private *);