]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
lmdb-safe: Do not use strerror() which is not thread-safe 15739/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 27 Jun 2025 19:54:41 +0000 (21:54 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 27 Jun 2025 19:54:41 +0000 (21:54 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
ext/lmdb-safe/lmdb-safe.cc

index cb8f1885fa6ca71321aafaf271daca8185460a74..a9fd848034b153e23d6f961e21783bc4d478a235 100644 (file)
@@ -183,18 +183,18 @@ std::shared_ptr<MDBEnv> 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<std::mutex> 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<MDBEnv>(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});