mdbx: add locking while open/close/drop dbi-handles (avoid dbi-related races).

This avoid races and collisions between threads when opening,
closing and deleting DBI-handles.

unfortunately, this does not resolve collision in the case an one thread
closing the DBI-handle while the another thread performs transaction.

Change-Id: I48c3ffb11a8f83739fae1712db3476645f573e09
This commit is contained in:
Leo Yuriev
2017-05-28 18:50:09 +03:00
parent bd5d092a2b
commit 0f676db491
2 changed files with 54 additions and 18 deletions

View File

@@ -603,6 +603,7 @@ struct MDBX_env {
unsigned me_maxreaders; /* size of the reader table */
/* Max MDBX_lockinfo.mti_numreaders of interest to mdbx_env_close() */
unsigned me_close_readers;
mdbx_fastmutex_t me_dbi_lock;
MDBX_dbi me_numdbs; /* number of DBs opened */
MDBX_dbi me_maxdbs; /* size of the DB table */
mdbx_pid_t me_pid; /* process ID of this env */