loom: loom::std::parking_lot::RwLock try_read/try_write methods block#7587
loom: loom::std::parking_lot::RwLock try_read/try_write methods block#7587Darksonn merged 1 commit intotokio-rs:masterfrom
Conversation
57772b9 to
ffbc46b
Compare
bd4ccae introduced a wrapper for the RwLock to get rid of poisoning aspects. By mistake (?!) its try_read/write methods actually delegate to read/write() and this would lead to blocking Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
|
Huh ... are these methods used anywhere? |
No idea. |
|
Yes definitely it should be fixed. Try removing them and see if it still compiles. |
Yep, that's definitely a copy/paste mistake. I cannot completely remember why I added those functions to the type (I guess because the Mutex implementation I took for inspiration had them, too). So they should either be removed or call the |
|
Removing the diff --git i/tokio/src/loom/std/parking_lot.rs w/tokio/src/loom/std/parking_lot.rs
index 9367ae01..154c9607 100644
--- i/tokio/src/loom/std/parking_lot.rs
+++ w/tokio/src/loom/std/parking_lot.rs
@@ -100,21 +100,9 @@ impl<T> RwLock<T> {
RwLockReadGuard(PhantomData, self.1.read())
}
- pub(crate) fn try_read(&self) -> Option<RwLockReadGuard<'_, T>> {
- self.1
- .try_read()
- .map(|guard| RwLockReadGuard(PhantomData, guard))
- }
-
pub(crate) fn write(&self) -> RwLockWriteGuard<'_, T> {
RwLockWriteGuard(PhantomData, self.1.write())
}
-
- pub(crate) fn try_write(&self) -> Option<RwLockWriteGuard<'_, T>> {
- self.1
- .try_write()
- .map(|guard| RwLockWriteGuard(PhantomData, guard))
- }
}
|
Motivation
bd4ccae introduced a wrapper for the RwLock to get rid of poisoning aspects.
By mistake (?!) its try_read/write methods actually delegate to read/write() and this would lead to blocking
Solution
Delegate the to try_** methods of the delegate to avoid blocking.