diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-05-22 11:53:08 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-22 11:53:08 +0900 |
| commit | 76725e081d5bfb6a7285acce8b3427cf3f60df58 (patch) | |
| tree | 1a076f63c6bb1446d315f65dbe8de5bedcc5ff7d | |
| parent | 6ef4911b994a84591136d34185d3c17f2960a4df (diff) | |
| parent | 3b70c29103cce7b03b6f0fe465e1197a3b212179 (diff) | |
| download | rust-76725e081d5bfb6a7285acce8b3427cf3f60df58.tar.gz rust-76725e081d5bfb6a7285acce8b3427cf3f60df58.zip | |
Rollup merge of #97245 - m-ou-se:rwlock-state-typo, r=JohnTitor
Fix typo in futex RwLock::write_contended. I wrote `state` where I should've used `s`. This was spotted by `@Warrenren.` This change removes the unnecessary `s` variable to prevent that mistake. Fortunately, this typo didn't affect the correctness of the lock, as the second half of the condition (!has_writers_waiting) is enough for correctness, which explains why this mistake didn't show up during testing. Fixes https://github.com/rust-lang/rust/issues/97162
| -rw-r--r-- | library/std/src/sys/unix/locks/futex_rwlock.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/library/std/src/sys/unix/locks/futex_rwlock.rs b/library/std/src/sys/unix/locks/futex_rwlock.rs index 57f6d58840d..5ff1aba7974 100644 --- a/library/std/src/sys/unix/locks/futex_rwlock.rs +++ b/library/std/src/sys/unix/locks/futex_rwlock.rs @@ -208,9 +208,8 @@ impl RwLock { // Don't go to sleep if the lock has become available, // or if the writers waiting bit is no longer set. - let s = self.state.load(Relaxed); - if is_unlocked(state) || !has_writers_waiting(s) { - state = s; + state = self.state.load(Relaxed); + if is_unlocked(state) || !has_writers_waiting(state) { continue; } |
