]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Only the call to mysql_init() needs to be protected by a mutex
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 20 May 2021 07:29:00 +0000 (09:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 18 Aug 2021 09:33:56 +0000 (11:33 +0200)
modules/gmysqlbackend/smysql.cc

index 35267c9e58f00edaf57658f79ec1d19c87c3ea31..b3ce048f19d86995e2e28ef2538a2887c8c743de 100644 (file)
@@ -476,13 +476,16 @@ void SMySQL::connect()
 {
   int retry = 1;
 
-  std::lock_guard<std::mutex> l(s_myinitlock);
-  if (d_threadCleanup) {
-    threadcloser.enable();
-  }
+  {
+    std::lock_guard<std::mutex> l(s_myinitlock);
+    if (d_threadCleanup) {
+      threadcloser.enable();
+    }
 
-  if (!mysql_init(&d_db))
-    throw sPerrorException("Unable to initialize mysql driver");
+    if (!mysql_init(&d_db)) {
+      throw sPerrorException("Unable to initialize mysql driver");
+    }
+  }
 
   do {