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

Remove TLS #14

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ fn init_loop(dest: &mut [u8]) -> Result<(), Error> {
let state = RNG_STATE.fetch_or(STATE_INIT_ONGOING, Ordering::AcqRel);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release ordering is about allowing clients who read STATE_INIT_ONGOING with Acquire ordering to synchronize with other shared state that you modified before writing to this variable. I do not think that it is useful here. If this is just a state flag, even Relaxed could be enough, as long as you use an Acquire fence as discussed above where necessary.


if state & STATE_INIT_ONGOING != 0 {
// initialization is not finished, so wait
thread::sleep(time::Duration::from_nanos(1));
thread::yield_now();
continue;
}
return if state & STATE_USE_SYSCALL != 0 {
Expand Down
3 changes: 1 addition & 2 deletions src/solaris_illumos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
let state = RNG_STATE.fetch_or(STATE_INIT_ONGOING, Ordering::AcqRel);
if state & STATE_INIT_DONE != 0 { break; }
if state & STATE_INIT_ONGOING != 0 {
// initialization is not finished, so wait
thread::sleep(time::Duration::from_nanos(1));
newpavlov marked this conversation as resolved.
Show resolved Hide resolved
thread::yield_now()
newpavlov marked this conversation as resolved.
Show resolved Hide resolved
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/use_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn init_loop() -> Result<RawFd, Error> {
}
}
// initialization is not finished, so wait
thread::sleep(time::Duration::from_nanos(1));
thread::yield_now();
}
}

Expand Down