diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/Cargo.toml | 2 | ||||
| -rw-r--r-- | runtime/ops/http.rs | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0bd8d13c4..356fb4694 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -55,7 +55,7 @@ dlopen = "0.1.8" encoding_rs = "0.8.28" filetime = "0.2.14" http = "0.2.3" -hyper = { version = "0.14.5", features = ["server", "stream", "http1", "http2", "runtime"] } +hyper = { version = "0.14.9", features = ["server", "stream", "http1", "http2", "runtime"] } indexmap = "1.6.2" lazy_static = "1.4.0" libc = "0.2.93" diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index fedcb404f..11e83f6c7 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -66,6 +66,7 @@ struct ServiceInner { #[derive(Clone, Default)] struct Service { inner: Rc<RefCell<Option<ServiceInner>>>, + waker: Rc<deno_core::futures::task::AtomicWaker>, } impl HyperService<Request<Body>> for Service { @@ -160,15 +161,16 @@ async fn op_http_request_next( let cancel = RcRef::map(conn_resource.clone(), |r| &r.cancel); poll_fn(|cx| { + conn_resource.deno_service.waker.register(cx.waker()); let connection_closed = match conn_resource.poll(cx) { Poll::Pending => false, Poll::Ready(Ok(())) => { - // close ConnResource - state + // try to close ConnResource, but don't unwrap as it might + // already be closed + let _ = state .borrow_mut() .resource_table - .take::<ConnResource>(conn_rid) - .unwrap(); + .take::<ConnResource>(conn_rid); true } Poll::Ready(Err(e)) => { @@ -188,7 +190,6 @@ async fn op_http_request_next( } } }; - if let Some(request_resource) = conn_resource.deno_service.inner.borrow_mut().take() { @@ -409,6 +410,9 @@ async fn op_http_response( }) .await?; + if maybe_response_body_rid.is_none() { + conn_resource.deno_service.waker.wake(); + } Ok(maybe_response_body_rid) } @@ -430,11 +434,13 @@ async fn op_http_response_close( .ok_or_else(bad_resource_id)?; drop(resource); - poll_fn(|cx| match conn_resource.poll(cx) { + let r = poll_fn(|cx| match conn_resource.poll(cx) { Poll::Ready(x) => Poll::Ready(x), Poll::Pending => Poll::Ready(Ok(())), }) - .await + .await; + conn_resource.deno_service.waker.wake(); + r } async fn op_http_request_read( |
