mirror of
https://github.com/denoland/deno.git
synced 2025-08-02 10:02:23 +00:00
Crashes while running wrk against
js/deps/https/deno.land/std/http/http_bench.ts
This reverts commit 972ac03858
.
This commit is contained in:
parent
a4551c853e
commit
1af02b405e
3 changed files with 40 additions and 110 deletions
|
@ -78,31 +78,14 @@ pub fn accept(r: Resource) -> Accept {
|
|||
pub struct Accept {
|
||||
state: AcceptState,
|
||||
}
|
||||
|
||||
impl Future for Accept {
|
||||
type Item = (TcpStream, SocketAddr);
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
let (stream, addr) = match self.state {
|
||||
// Similar to try_ready!, but also track/untrack accept task
|
||||
// in TcpListener resource.
|
||||
// In this way, when the listener is closed, the task can be
|
||||
// notified to error out (instead of stuck forever).
|
||||
AcceptState::Pending(ref mut r) => match r.poll_accept() {
|
||||
Ok(futures::prelude::Async::Ready(t)) => {
|
||||
r.untrack_task();
|
||||
t
|
||||
}
|
||||
Ok(futures::prelude::Async::NotReady) => {
|
||||
// Would error out if another accept task is being tracked.
|
||||
r.track_task()?;
|
||||
return Ok(futures::prelude::Async::NotReady);
|
||||
}
|
||||
Err(e) => {
|
||||
r.untrack_task();
|
||||
return Err(From::from(e));
|
||||
}
|
||||
},
|
||||
AcceptState::Pending(ref mut r) => try_ready!(r.poll_accept()),
|
||||
AcceptState::Empty => panic!("poll Accept after it's done"),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue