From: Howard Chu Date: Thu, 18 Apr 2013 02:17:03 +0000 (+0200) Subject: Add MDB_NOTLS envflag. X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~69^2~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=272e4e98ad7e792a91f9dfd056ee9fc9d0e0ebde;p=openldap Add MDB_NOTLS envflag. --- diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index b2525edfeb..4906472f24 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -66,6 +66,7 @@ * * - A thread can only use one transaction at a time, plus any child * transactions. Each transaction belongs to one thread. See below. + * The #MDB_NOTLS flag changes this for read-only transactions. * * - Use an MDB_env* in the process which opened it, without fork()ing. * @@ -249,6 +250,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel #define MDB_WRITEMAP 0x80000 /** use asynchronous msync when MDB_WRITEMAP is used */ #define MDB_MAPASYNC 0x100000 + /** tie reader locktable slots to #MDB_txn objects instead of to threads */ +#define MDB_NOTLS 0x200000 /** @} */ /** @defgroup mdb_dbi_open Database Flags @@ -392,8 +395,8 @@ typedef struct MDB_envinfo { size_t me_mapsize; /**< Size of the data memory map */ size_t me_last_pgno; /**< ID of the last used page */ size_t me_last_txnid; /**< ID of the last committed transaction */ - unsigned int me_maxreaders; /**< maximum number of threads for the environment */ - unsigned int me_numreaders; /**< maximum number of threads used in the environment */ + unsigned int me_maxreaders; /**< max reader slots in the environment */ + unsigned int me_numreaders; /**< max reader slots used in the environment */ } MDB_envinfo; /** @brief Return the mdb library version information. @@ -492,6 +495,15 @@ int mdb_env_create(MDB_env **env); * database or lose the last transactions. Calling #mdb_env_sync() * ensures on-disk database integrity until next commit. * This flag may be changed at any time using #mdb_env_set_flags(). + *
  • #MDB_NOTLS + * Don't use Thread-Local Storage. Tie reader locktable slots to + * #MDB_txn objects instead of to threads. I.e. #mdb_txn_reset() keeps + * the slot reseved for the #MDB_txn object. A thread may use parallel + * read-only transactions. A read-only transaction may span threads if + * the user synchronizes its use. Applications that multiplex many + * user threads over individual OS threads need this option. Such an + * application must also serialize the write transactions in an OS + * thread, since MDB's write locking is unaware of the user threads. * * @param[in] mode The UNIX permissions to set on created files. This parameter * is ignored on Windows. @@ -626,13 +638,17 @@ int mdb_env_get_path(MDB_env *env, const char **path); */ int mdb_env_set_mapsize(MDB_env *env, size_t size); - /** @brief Set the maximum number of threads for the environment. + /** @brief Set the maximum number of threads/reader slots for the environment. * * This defines the number of slots in the lock table that is used to track readers in the * the environment. The default is 126. + * Starting a read-only transaction normally ties a lock table slot to the + * current thread until the environment closes or the thread exits. If + * MDB_NOTLS is in use, #mdb_txn_begin() instead ties the slot to the + * MDB_txn object until it or the #MDB_env object is destroyed. * This function may only be called after #mdb_env_create() and before #mdb_env_open(). * @param[in] env An environment handle returned by #mdb_env_create() - * @param[in] readers The maximum number of threads + * @param[in] readers The maximum number of reader lock table slots * @return A non-zero error value on failure and 0 on success. Some possible * errors are: *