Skip to content

Commit

Permalink
fix the leak
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed Jan 28, 2021
1 parent 468c3b1 commit b54812f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tokio/src/io/driver/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ impl Registration {
}
}

impl Drop for Registration {
fn drop(&mut self) {
self.shared.clear_wakers();
}
}

fn gone() -> io::Error {
io::Error::new(io::ErrorKind::Other, "IO driver has terminated")
}
Expand Down
6 changes: 6 additions & 0 deletions tokio/src/io/driver/scheduled_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ impl ScheduledIo {
// result isn't important
let _ = self.set_readiness(None, Tick::Clear(event.tick), |curr| curr - mask_no_closed);
}

pub(crate) fn clear_wakers(&self) {
let mut waiters = self.waiters.lock();
waiters.reader.take();
waiters.writer.take();
}
}

impl Drop for ScheduledIo {
Expand Down

0 comments on commit b54812f

Please sign in to comment.