]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Make the health-check latency atomic 16192/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 29 Sep 2025 12:39:14 +0000 (14:39 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 29 Sep 2025 12:39:14 +0000 (14:39 +0200)
Otherwise TSAN rightfully complain that it is written from one thread
and read from several others.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-healthchecks.cc
pdns/dnsdistdist/dnsdist.hh

index e0d82f8bf6c99848f0f06ce51f6de542d1d3e437..3081efdcb1a7a16bb1b9ea7e25d55d1fcb4f5536 100644 (file)
@@ -134,7 +134,7 @@ static bool handleResponse(std::shared_ptr<HealthCheckData>& data)
     return false;
   }
 
-  data->d_ds->d_healthCheckLatency = data->d_elapsed.udiff();
+  data->d_ds->d_healthCheckLatency.store(data->d_elapsed.udiff());
   return true;
 }
 
index ecc1caca665c2b26d3063e5a2d33b94189c7dfaf..eff68ab13b11b1d56041daefe1446f92e4f244b8 100644 (file)
@@ -719,10 +719,10 @@ public:
   std::vector<std::shared_ptr<XskSocket>> d_xskSockets;
 #endif
   std::atomic<uint64_t> idOffset{0};
+  std::atomic<double> d_healthCheckLatency{0.0};
   size_t socketsOffset{0};
   double latencyUsec{0.0};
   double latencyUsecTCP{0.0};
-  double d_healthCheckLatency{0.0};
   unsigned int d_nextCheck{0};
   uint16_t currentCheckFailures{0};
   std::atomic<bool> hashesComputed{false};