From e585bf0a4188bfde1ded2045954bb30ce9610b7e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 12 Jun 2024 11:25:12 +0200 Subject: [PATCH] dns-test: make NameServer's FQDN more stable previously, the FQDN of a NameServer was generated using a globally shared, monotonically increasing counter. that resulted in a unpredictable FQDN in the presence other tests running concurrently / in parallel with this change, the presence of other test threads does not affect the FQDN automatically chosen for a NameServer. the FQDN becomes only a function of the order in which the NameServers are created *within a thread* --- conformance/packages/dns-test/src/name_server.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conformance/packages/dns-test/src/name_server.rs b/conformance/packages/dns-test/src/name_server.rs index 4db1c0c3..2ee6aeb2 100644 --- a/conformance/packages/dns-test/src/name_server.rs +++ b/conformance/packages/dns-test/src/name_server.rs @@ -317,8 +317,10 @@ fn zone_file_path() -> String { } fn ns_count() -> usize { - static COUNT: AtomicUsize = AtomicUsize::new(0); - COUNT.fetch_add(1, atomic::Ordering::Relaxed) + thread_local! { + static COUNT: AtomicUsize = const { AtomicUsize::new(0) }; + } + COUNT.with(|count| count.fetch_add(1, atomic::Ordering::Relaxed)) } impl NameServer {