From 7ad3b74ea624b47441f717ad7ced209ef01869c8 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 27 Jun 2025 21:54:41 +0200 Subject: [PATCH] lmdb-safe: Do not use strerror() which is not thread-safe Signed-off-by: Remi Gacogne --- ext/lmdb-safe/lmdb-safe.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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}); -- 2.47.2