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*
This commit is contained in:
Jorge Aparicio 2024-06-12 11:25:12 +02:00 committed by Benjamin Fry
parent ed192864f3
commit e585bf0a41

View File

@ -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<Signed> {