]> git.ipfire.org Git - thirdparty/pdns.git/commit
lmdb-safe: Fix a small race in `getMDBEnv`
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 27 Jun 2025 14:40:38 +0000 (16:40 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 2 Jul 2025 14:12:00 +0000 (16:12 +0200)
commit6bf03e03658ae8535b78f2b22c99298c2074c391
treed8ad2e3bd7c9779aa56631f2788de57f941b2993
parent92e5c645f2fb8e700020c7eecd054e502f767acf
lmdb-safe: Fix a small race in `getMDBEnv`

I believe there is a small race in the `getMDBEnv`: if the database
file does not exist when we first try to get the file metadata, we
acquire the lock then create a new `MDBEnv` and store it in the map.
But what happens if a different thread created the database between
our first check and the call to `MDBEnv`? I believe we would create
a new environment and override the existing entry in the map, bypassing
the check.
This commit introduces a second check right after acquiring the lock
to prevent that.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit 57224e94d9189f4916bbd7b2aaf61fa0821b1a2c)
ext/lmdb-safe/lmdb-safe.cc