From: Howard Chu Date: Mon, 21 Oct 2013 17:29:38 +0000 (-0700) Subject: Add mdb_env_get_fd() X-Git-Tag: OPENLDAP_REL_ENG_2_4_37~2^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b86f08e9d6f083d20c81054e2fff0d54695a4a2e;p=openldap Add mdb_env_get_fd() Return the environment's filedescriptor. Useful when the caller is doing their own locking. --- diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index f72869e6c8..f6d0a0af1f 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -679,6 +679,18 @@ int mdb_env_get_flags(MDB_env *env, unsigned int *flags); */ int mdb_env_get_path(MDB_env *env, const char **path); + /** @brief Return the filedescriptor for the given environment. + * + * @param[in] env An environment handle returned by #mdb_env_create() + * @param[out] fd Address of a mdb_filehandle_t to contain the descriptor. + * @return A non-zero error value on failure and 0 on success. Some possible + * errors are: + * + */ +int mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *fd); + /** @brief Set the size of the memory map to use for this environment. * * The size should be a multiple of the OS page size. The default is diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index e52da918a4..33be87672d 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -7817,6 +7817,16 @@ mdb_env_get_path(MDB_env *env, const char **arg) return MDB_SUCCESS; } +int +mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *arg) +{ + if (!env || !arg) + return EINVAL; + + *arg = env->me_fd; + return MDB_SUCCESS; +} + /** Common code for #mdb_stat() and #mdb_env_stat(). * @param[in] env the environment to operate in. * @param[in] db the #MDB_db record containing the stats to return.