Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential to modify ordering for IS_TEST in lib module #736

Open
wang384670111 opened this issue Mar 3, 2024 · 1 comment
Open

Potential to modify ordering for IS_TEST in lib module #736

wang384670111 opened this issue Mar 3, 2024 · 1 comment

Comments

@wang384670111
Copy link

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)

@algesten
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants