1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

Drop assert!() from untrack_task() (#1757)

This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2019-02-12 18:51:45 -08:00 committed by Ryan Dahl
parent f29c40a433
commit 163c334521
2 changed files with 6 additions and 1 deletions

View file

@ -202,7 +202,8 @@ impl Resource {
let mut table = RESOURCE_TABLE.lock().unwrap();
// Only untrack if is TcpListener.
if let Some(Repr::TcpListener(_, t)) = table.get_mut(&self.rid) {
assert!(t.is_some());
// DO NOT assert is_some here.
// See reasoning in Accept::poll().
t.take();
}
}

View file

@ -69,6 +69,10 @@ impl Future for Accept {
// notified to error out (instead of stuck forever).
AcceptState::Pending(ref mut r) => match r.poll_accept() {
Ok(futures::prelude::Async::Ready(t)) => {
// Notice: it is possible to be Ready on the first poll.
// When eager accept fails due to WouldBlock,
// a next poll() might still be immediately Ready.
// See https://github.com/denoland/deno/issues/1756.
r.untrack_task();
t
}