From 1bddc9dcbc15cd9fc2526bc63c92fcf486127dfa Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Sun, 23 Apr 2017 18:58:38 +0300 Subject: [PATCH] mdbx: change mdbx_canary_get() API. Change-Id: Ie8831d8acb7113916b8a44b870596a9bf1ccc8b2 --- mdbx.h | 2 +- src/mdbx.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mdbx.h b/mdbx.h index ae9e5ca5..1ecfcef3 100644 --- a/mdbx.h +++ b/mdbx.h @@ -1728,7 +1728,7 @@ LIBMDBX_API int mdbx_env_pgwalk(MDB_txn *txn, MDBX_pgvisitor_func *visitor, typedef struct mdbx_canary { uint64_t x, y, z, v; } mdbx_canary; LIBMDBX_API int mdbx_canary_put(MDB_txn *txn, const mdbx_canary *canary); -LIBMDBX_API size_t mdbx_canary_get(MDB_txn *txn, mdbx_canary *canary); +LIBMDBX_API int mdbx_canary_get(MDB_txn *txn, mdbx_canary *canary); /* Returns: * - MDBX_RESULT_TRUE when no more data available diff --git a/src/mdbx.c b/src/mdbx.c index 003ef5ed..3ed4c46d 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -9792,14 +9792,14 @@ int mdbx_canary_put(MDB_txn *txn, const mdbx_canary *canary) { return MDB_SUCCESS; } -size_t mdbx_canary_get(MDB_txn *txn, mdbx_canary *canary) { - if (unlikely(!txn || txn->mt_signature != MDBX_MT_SIGNATURE)) - return 0; +int mdbx_canary_get(MDB_txn *txn, mdbx_canary *canary) { + if (unlikely(txn == NULL || canary == NULL)) + return EINVAL; + if (unlikely(txn->mt_signature != MDBX_MT_SIGNATURE)) + return MDBX_EBADSIGN; - if (likely(canary)) - *canary = txn->mt_canary; - - return txn->mt_txnid; + *canary = txn->mt_canary; + return MDB_SUCCESS; } int mdbx_cursor_on_first(MDB_cursor *mc) {