mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:24:14 +08:00
mdbx-posix: refine mdbx_lck_init(), allow multi-opending with MDBX_LOCKING_SYSV.
This commit is contained in:
parent
0bb950ad55
commit
35313d18bc
@ -1,6 +1,7 @@
|
||||
v0.9.x (in the development):
|
||||
- TODO: Native bindings for C++.
|
||||
- TODO: Packages for AltLinux, Fedora/RHEL, Debian/Ubuntu.
|
||||
- Support multi-opening the same DB in a process with SysV locking (BSD).
|
||||
|
||||
v0.8.1 2020-06-12:
|
||||
- Minor change versioning. The last number in version now mean the number of commits since last release/tag.
|
||||
|
@ -538,13 +538,11 @@ MDBX_INTERNAL_FUNC int __cold mdbx_lck_destroy(MDBX_env *env,
|
||||
MDBX_INTERNAL_FUNC int __cold mdbx_lck_init(MDBX_env *env,
|
||||
MDBX_env *inprocess_neighbor,
|
||||
int global_uniqueness_flag) {
|
||||
if (inprocess_neighbor)
|
||||
return MDBX_SUCCESS /* currently don't need any initialization
|
||||
if LCK already opened/used inside current process */
|
||||
;
|
||||
#if MDBX_LOCKING == MDBX_LOCKING_SYSV
|
||||
int semid = -1;
|
||||
if (global_uniqueness_flag) {
|
||||
/* don't initialize semaphores twice */
|
||||
(void)inprocess_neighbor;
|
||||
if (global_uniqueness_flag == MDBX_RESULT_TRUE) {
|
||||
struct stat st;
|
||||
if (fstat(env->me_lazy_fd, &st))
|
||||
return errno;
|
||||
@ -588,14 +586,17 @@ MDBX_INTERNAL_FUNC int __cold mdbx_lck_init(MDBX_env *env,
|
||||
}
|
||||
|
||||
env->me_sysv_ipc.semid = semid;
|
||||
|
||||
return MDBX_SUCCESS;
|
||||
|
||||
#elif MDBX_LOCKING == MDBX_LOCKING_FUTEX
|
||||
#warning "TODO"
|
||||
(void)inprocess_neighbor;
|
||||
if (global_uniqueness_flag != MDBX_RESULT_TRUE)
|
||||
return MDBX_SUCCESS;
|
||||
#error "FIXME: Not implemented"
|
||||
#elif MDBX_LOCKING == MDBX_LOCKING_POSIX1988
|
||||
|
||||
/* don't initialize semaphores twice */
|
||||
(void)inprocess_neighbor;
|
||||
if (global_uniqueness_flag == MDBX_RESULT_TRUE) {
|
||||
if (sem_init(&env->me_lck->mti_rlock, true, 1))
|
||||
return errno;
|
||||
@ -606,6 +607,10 @@ MDBX_INTERNAL_FUNC int __cold mdbx_lck_init(MDBX_env *env,
|
||||
|
||||
#elif MDBX_LOCKING == MDBX_LOCKING_POSIX2001 || \
|
||||
MDBX_LOCKING == MDBX_LOCKING_POSIX2008
|
||||
if (inprocess_neighbor)
|
||||
return MDBX_SUCCESS /* don't need any initialization for mutexes
|
||||
if LCK already opened/used inside current process */
|
||||
;
|
||||
|
||||
/* FIXME: Unfortunately, there is no other reliable way but to long testing
|
||||
* on each platform. On the other hand, behavior like FreeBSD is incorrect
|
||||
|
Loading…
x
Reference in New Issue
Block a user