From: Remi Gacogne Date: Fri, 27 Jun 2025 19:54:41 +0000 (+0200) Subject: lmdb-safe: Do not use strerror() which is not thread-safe X-Git-Tag: rec-5.3.0-alpha2~37^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ad3b74ea624b47441f717ad7ced209ef01869c8;p=thirdparty%2Fpdns.git lmdb-safe: Do not use strerror() which is not thread-safe Signed-off-by: Remi Gacogne --- diff --git a/ext/lmdb-safe/lmdb-safe.cc b/ext/lmdb-safe/lmdb-safe.cc index cb8f1885fa..a9fd848034 100644 --- a/ext/lmdb-safe/lmdb-safe.cc +++ b/ext/lmdb-safe/lmdb-safe.cc @@ -183,18 +183,18 @@ std::shared_ptr getMDBEnv(const char* fname, int flags, int mode, uint64 struct stat statbuf{}; if (stat(fname, &statbuf) != 0) { if (errno != ENOENT) { - throw std::runtime_error("Unable to stat prospective mdb database: "+string(strerror(errno))); + throw std::runtime_error("Unable to stat prospective mdb database: " + MDBError(errno)); } std::lock_guard lock(mut); /* we need to check again _after_ taking the lock, otherwise a different thread might have created it in the meantime */ if (stat(fname, &statbuf) != 0) { if (errno != ENOENT) { - throw std::runtime_error("Unable to stat prospective mdb database: "+string(strerror(errno))); + throw std::runtime_error("Unable to stat prospective mdb database: " + MDBError(errno)); } auto fresh = std::make_shared(fname, flags, mode, mapsizeMB); if (stat(fname, &statbuf) != 0) { - throw std::runtime_error("Unable to stat prospective mdb database: "+string(strerror(errno))); + throw std::runtime_error("Unable to stat prospective mdb database: " + MDBError(errno)); } auto key = std::tie(statbuf.st_dev, statbuf.st_ino); s_envs.emplace(key, Value{fresh, flags});