From: Howard Chu Date: Thu, 18 Jul 2013 14:41:11 +0000 (-0700) Subject: Add mdb_reader_list() X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~32^2~7 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=49289f0d2e8b5b2fb0295606938c2a4007800e3b;p=openldap Add mdb_reader_list() Dump the active slots in the reader table. --- diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index c38c7dbf8f..af046d19c8 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -1298,6 +1298,23 @@ int mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b); * @return < 0 if a < b, 0 if a == b, > 0 if a > b */ int mdb_dcmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b); + + /** @brief A callback function used to print a message from the library. + * + * @param[in] msg The string to be printed. + * @param[in] ctx An arbitrary context pointer for the callback. + * @return < 0 on failure, 0 on success. + */ +typedef int (MDB_msg_func)(const char *msg, void *ctx); + + /** @brief Dump the entries in the reader lock table. + * + * @param[in] env An environment handle returned by #mdb_env_create() + * @param[in] func A #MDB_msg_func function + * @param[in] ctx Anything the message function needs + * @return < 0 on failure, 0 on success. + */ +int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx); /** @} */ #ifdef __cplusplus diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index f895c0fb5e..f86ec356b6 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -7916,4 +7916,39 @@ int mdb_set_relctx(MDB_txn *txn, MDB_dbi dbi, void *ctx) return MDB_SUCCESS; } +int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx) +{ + unsigned int i, rdrs; + MDB_reader *mr; + char buf[128]; + int first = 1; + + if (!env || !func) + return -1; + if (!env->me_txns) { + return func("No reader locks\n", ctx); + } + rdrs = env->me_numreaders; + mr = env->me_txns->mti_readers; + for (i=0; i