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) {