]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
This should eliminate a dozen or so Coverity warnigs 15168/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Feb 2025 08:15:34 +0000 (09:15 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Feb 2025 08:15:34 +0000 (09:15 +0100)
For example:

1591605 Data race condition

5. missing_lock: Accessing g_lowercaseOutgoing without holding lock LockGuarded<std::shared_ptr<std::unordered_map<DNSName, SyncRes::AuthDomain, std::hash<DNSName>, std::equal_to<DNSName>, std::allocator<std::pair<DNSName const, SyncRes::AuthDomain> > > > >.d_mutex. Elsewhere, g_lowercaseOutgoing is written to with LockGuarded.d_mutex held 1 out of 1 times.

pdns/recursordist/rec-main.cc

index 0666317678b388eebf8c2f514d5e2da7427e4e52..0e2a66a55f71dbc1d929ff925a80d2eea3130467 100644 (file)
@@ -2233,7 +2233,10 @@ static int serviceMain(Logr::log_t log)
   }
   g_networkTimeoutMsec = ::arg().asNum("network-timeout");
 
-  std::tie(*g_initialDomainMap.lock(), *g_initialAllowNotifyFor.lock()) = parseZoneConfiguration(g_yamlSettings);
+  { // Reduce scope of locks (otherwise Coverity induces from this line the global vars below should be
+    // protected by a mutex)
+    std::tie(*g_initialDomainMap.lock(), *g_initialAllowNotifyFor.lock()) = parseZoneConfiguration(g_yamlSettings);
+  }
 
   g_latencyStatSize = ::arg().asNum("latency-statistic-size");