the only remaining user.
When closing an lmdb database, all memory and file descriptor resources
are released, including the shared memory pages that contained the
robust mutex.
However, before this commit, prior to unmapping the pages that contained
the robust mutexex, lmdb did not destroy the mutexes first. This would
create a problem when an application opens and closes a database, then
open it again.
According to libthr(3), by default, a shared lock backed by a mapped
file in memory is automatically destroyed on the last unmap of the
corresponding file' page, which is allowed by POSIX.
After unmapping the shared pages, the kernel writes off all active
robust mutexes associated with these pages. However, the userland
threading library still keeps the record (pshared_lookup in
thr_pshared.c of libthr) for these objects as they are not really
destroyed before, so that it don't have to ask the kernel every
time when looking them up.
Now, a later re-open of the database might have mapped the lock file
to the same memory location. Because the threading library have
remembered the robust mutex object, it would just reuse it even though
it was already invalid from kernel's point of view. Unfortunately,
regular lock operations would still work for this process.
Should another lmdb process opens the same database, it would attempt
to obtain the robust mutex (no longer recognized by kernel) because it
would see another process holding a file lock, but that would fail
because the robust mutex is invalid for the kernel.
Explicitly destroy the mutex if we are the last remaining user to ensure
the mutex is always in a known defined state.
OpenLDAP ITS #9278
With debugging help from: kib
PR: 244493
MFH: 2020Q2
Robust mutexes were already enabled but r478269 disabled POSIX
semaphores. It appears both are only mutually exclusive on Android and
old GNU libc.
PR: 230564
Reported by: Volodymyr Kostyrko
Pointy hat to: jbeich
LMDB 0.9.22 Release (2018-03-22)
Fix MDB_DUPSORT alignment bug (ITS#8819)
Fix regression with new db from 0.9.19 (ITS#8760)
Fix liblmdb to build on Solaris (ITS#8612)
Fix delete behavior with DUPSORT DB (ITS#8622)
Fix mdb_cursor_get/mdb_cursor_del behavior (ITS#8722)
PR: 227103
Submitted by: gahr
Approved by: delphij (maintainer)
Using soname allows pkg(8) to register the library, and it helps on
upgrades.
Use WRKSRC_SUBDIR
Use MAKE_ARGS instead of MAKE_ENV so the patch can be simplified.
PR: 211700
Submitted by: mat
Approved by: delphij (maintainer)
Sponsored by: Absolight
Since FreeBSD 8.4 and FreeBSD 9.1 make(1) do support :tu and :tl as a
replacement for :U and :L (which has been marked as deprecated)
bmake which is the default on FreeBSD 10+ only support by default
:tu/:tl a hack has been added at the time to support :U and :L to ease
migration. This hack is now not necessary anymore
Note that this makes the ports tree incompatible with make(1) from
FreeBSD 8.3 or earlier
With hat: portmgr