diff options
author | Andrew Bartlett <abartlet@samba.org> | 2017-06-15 12:10:51 +1200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2017-07-02 17:35:19 +0200 |
commit | 6a3e77edc31b356865c5d7b9e6e1567b2d48c9f6 (patch) | |
tree | 31d021db9e461617f0334a86909505882ecb9027 /lib | |
parent | 31ef1d6211f4bc448beca8da5d584624ba1ed68f (diff) | |
download | samba-6a3e77edc31b356865c5d7b9e6e1567b2d48c9f6.tar.gz |
ldb: Add read_lock and read_unlock to ldb_module_ops
This will be used to implement read locking in ldb_tdb
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/ABI/ldb-1.1.31.sigs | 2 | ||||
-rw-r--r-- | lib/ldb/common/ldb_modules.c | 46 | ||||
-rw-r--r-- | lib/ldb/include/ldb_module.h | 4 |
3 files changed, 52 insertions, 0 deletions
diff --git a/lib/ldb/ABI/ldb-1.1.31.sigs b/lib/ldb/ABI/ldb-1.1.31.sigs index d183708b215..1be2ae73a2f 100644 --- a/lib/ldb/ABI/ldb-1.1.31.sigs +++ b/lib/ldb/ABI/ldb-1.1.31.sigs @@ -186,6 +186,8 @@ ldb_next_del_trans: int (struct ldb_module *) ldb_next_end_trans: int (struct ldb_module *) ldb_next_init: int (struct ldb_module *) ldb_next_prepare_commit: int (struct ldb_module *) +ldb_next_read_lock: int (struct ldb_module *) +ldb_next_read_unlock: int (struct ldb_module *) ldb_next_remote_request: int (struct ldb_module *, struct ldb_request *) ldb_next_request: int (struct ldb_module *, struct ldb_request *) ldb_next_start_trans: int (struct ldb_module *) diff --git a/lib/ldb/common/ldb_modules.c b/lib/ldb/common/ldb_modules.c index ca93299ab00..3dd0438c128 100644 --- a/lib/ldb/common/ldb_modules.c +++ b/lib/ldb/common/ldb_modules.c @@ -641,6 +641,52 @@ int ldb_next_end_trans(struct ldb_module *module) return ret; } +int ldb_next_read_lock(struct ldb_module *module) +{ + int ret; + FIND_OP(module, read_lock); + ret = module->ops->read_lock(module); + if (ret == LDB_SUCCESS) { + return ret; + } + if (!ldb_errstring(module->ldb)) { + /* Set a default error string, to place the blame somewhere */ + ldb_asprintf_errstring(module->ldb, + "read_lock error in module %s: %s (%d)", + module->ops->name, ldb_strerror(ret), + ret); + } + if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { + ldb_debug(module->ldb, LDB_DEBUG_TRACE, + "ldb_next_read_lock error: %s", + ldb_errstring(module->ldb)); + } + return ret; +} + +int ldb_next_read_unlock(struct ldb_module *module) +{ + int ret; + FIND_OP(module, read_unlock); + ret = module->ops->read_unlock(module); + if (ret == LDB_SUCCESS) { + return ret; + } + if (!ldb_errstring(module->ldb)) { + /* Set a default error string, to place the blame somewhere */ + ldb_asprintf_errstring(module->ldb, + "read_unlock error in module %s: %s (%d)", + module->ops->name, ldb_strerror(ret), + ret); + } + if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { + ldb_debug(module->ldb, LDB_DEBUG_TRACE, + "ldb_next_read_unlock error: %s", + ldb_errstring(module->ldb)); + } + return ret; +} + int ldb_next_prepare_commit(struct ldb_module *module) { int ret; diff --git a/lib/ldb/include/ldb_module.h b/lib/ldb/include/ldb_module.h index 3d56e68eddd..0f5feeb084c 100644 --- a/lib/ldb/include/ldb_module.h +++ b/lib/ldb/include/ldb_module.h @@ -77,6 +77,8 @@ struct ldb_module_ops { int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); int (*sequence_number)(struct ldb_module *, struct ldb_request *); + int (*read_lock)(struct ldb_module *); + int (*read_unlock)(struct ldb_module *); void *private_data; }; @@ -203,6 +205,8 @@ int ldb_next_end_trans(struct ldb_module *module); int ldb_next_del_trans(struct ldb_module *module); int ldb_next_prepare_commit(struct ldb_module *module); int ldb_next_init(struct ldb_module *module); +int ldb_next_read_lock(struct ldb_module *module); +int ldb_next_read_unlock(struct ldb_module *module); void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); |