algesten / ureq

A simple, safe HTTP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential to modify ordering for IS_TEST in lib module

wang384670111 opened this issue · comments

ureq/src/lib.rs

Lines 479 to 485 in 4e3169f

pub fn is_test(is: bool) -> bool {
static IS_TEST: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
if is {
IS_TEST.store(true, Ordering::SeqCst);
}
IS_TEST.load(Ordering::SeqCst)
}

SeqCst is overly restrictive. I believe that the ordering can be appropriately modified.

In lib model, I believe that IS_TEST is merely signals for multithreading purposes and do not synchronize with other locals. Therefore, using Relaxed ordering should suffice.

(happy to make a PR if this looks reasonable)

Sure PR is good. Doesn't make any difference really since this is not a very used code path.