diff options
author | Zahari Dichev <zaharidichev@gmail.com> | 2020-09-25 18:38:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-25 08:38:13 -0700 |
commit | 444660664b96f758610a0e7201a6a1a31a0f2405 (patch) | |
tree | 0b6829c695a5a0e2cec1157f84ecbe10a0780a3c /tokio/src/io/driver | |
parent | cf025ba45f68934ae2138bb75ee2a5ee50506d1b (diff) |
chore: handle std `Mutex` poisoning in a shim (#2872)
As tokio does not rely on poisoning, we can
avoid always unwrapping when locking by handling
the `PoisonError` in the Mutex shim.
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
Diffstat (limited to 'tokio/src/io/driver')
-rw-r--r-- | tokio/src/io/driver/scheduled_io.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tokio/src/io/driver/scheduled_io.rs b/tokio/src/io/driver/scheduled_io.rs index 3e7d9570..88daeb2d 100644 --- a/tokio/src/io/driver/scheduled_io.rs +++ b/tokio/src/io/driver/scheduled_io.rs @@ -193,7 +193,7 @@ impl ScheduledIo { } pub(super) fn wake(&self, ready: mio::Ready) { - let mut waiters = self.waiters.lock().unwrap(); + let mut waiters = self.waiters.lock(); // check for AsyncRead slot if !(ready & (!mio::Ready::writable())).is_empty() { @@ -241,7 +241,7 @@ impl ScheduledIo { if ready.is_empty() { // Update the task info - let mut waiters = self.waiters.lock().unwrap(); + let mut waiters = self.waiters.lock(); let slot = match direction { Direction::Read => &mut waiters.reader, Direction::Write => &mut waiters.writer, @@ -375,7 +375,7 @@ cfg_io_readiness! { } // Wasn't ready, take the lock (and check again while locked). - let mut waiters = scheduled_io.waiters.lock().unwrap(); + let mut waiters = scheduled_io.waiters.lock(); let curr = scheduled_io.readiness.load(SeqCst); let readiness = mio::Ready::from_usize(READINESS.unpack(curr)); @@ -408,7 +408,7 @@ cfg_io_readiness! { // `notify.waiters`). In order to access the waker fields, // we must hold the lock. - let waiters = scheduled_io.waiters.lock().unwrap(); + let waiters = scheduled_io.waiters.lock(); // Safety: called while locked let w = unsafe { &mut *waiter.get() }; @@ -450,7 +450,7 @@ cfg_io_readiness! { impl Drop for Readiness<'_> { fn drop(&mut self) { - let mut waiters = self.scheduled_io.waiters.lock().unwrap(); + let mut waiters = self.scheduled_io.waiters.lock(); // Safety: `waiter` is only ever stored in `waiters` unsafe { |