Skip to content

Commit

Permalink
Combine the load+store into a swap
Browse files Browse the repository at this point in the history
  • Loading branch information
MolotovCherry committed Nov 8, 2024
1 parent 84ce831 commit 75f4ed0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crates/yabg3nml/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,11 @@ pub fn server() -> io::Result<Infallible> {
return ControlFlow::Break(());
}

// load current auth code
let passcode = AUTH.load(Ordering::Relaxed);
// load current auth code; also change auth code to always keep it randomized
let passcode = AUTH.swap(rand::random::<u64>(), Ordering::Relaxed);

trace!(code, passcode, "verifying auth code");

// change auth code to always keep it randomized
let auth_code = rand::random::<u64>();
AUTH.store(auth_code, Ordering::Relaxed);

if passcode == code {
ControlFlow::Continue(())
} else {
Expand Down

0 comments on commit 75f4ed0

Please sign in to comment.