summaryrefslogtreecommitdiff
path: root/runtime/ops/http.rs
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2021-05-10 23:49:57 +0000
committerBert Belder <bertbelder@gmail.com>2021-05-11 03:11:26 +0200
commit640d431b35860913ed376cf781da1b8b1a73d0a4 (patch)
tree96ad522d8a212505c4e8a66ee406d3370adf5e87 /runtime/ops/http.rs
parent36c5461129a1b769eb205765a79c5dc000b0b2f6 (diff)
fix(tls): flush send buffer in the background after closing TLS stream (#10146)
In #9118, TLS streams were split into a "read half" and a "write half" using tokio::io::split() to allow concurrent Conn#read() and Conn#write() calls without one blocking the other. However, this introduced a bug: outgoing data gets discarded when the TLS stream is gracefully closed, because the read half is closed too early, before all TLS control data has been received. Fixes: #9692 Fixes: #10049 Fixes: #10296 Fixes: denoland/deno_std#750
Diffstat (limited to 'runtime/ops/http.rs')
-rw-r--r--runtime/ops/http.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs
index 3642a0ac3..e4ba2db2a 100644
--- a/runtime/ops/http.rs
+++ b/runtime/ops/http.rs
@@ -1,7 +1,8 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use crate::ops::io::TcpStreamResource;
-use crate::ops::io::TlsServerStreamResource;
+use crate::ops::io::TlsStreamResource;
+use crate::ops::tls::TlsStream;
use deno_core::error::bad_resource_id;
use deno_core::error::null_opbuf;
use deno_core::error::type_error;
@@ -43,7 +44,6 @@ use std::task::Poll;
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio::sync::oneshot;
-use tokio_rustls::server::TlsStream;
use tokio_util::io::StreamReader;
pub fn init() -> Extension {
@@ -100,7 +100,7 @@ impl HyperService<Request<Body>> for Service {
enum ConnType {
Tcp(Rc<RefCell<Connection<TcpStream, Service, LocalExecutor>>>),
- Tls(Rc<RefCell<Connection<TlsStream<TcpStream>, Service, LocalExecutor>>>),
+ Tls(Rc<RefCell<Connection<TlsStream, Service, LocalExecutor>>>),
}
struct ConnResource {
@@ -305,12 +305,12 @@ fn op_http_start(
if let Some(resource_rc) = state
.resource_table
- .take::<TlsServerStreamResource>(tcp_stream_rid)
+ .take::<TlsStreamResource>(tcp_stream_rid)
{
let resource = Rc::try_unwrap(resource_rc)
.expect("Only a single use of this resource should happen");
let (read_half, write_half) = resource.into_inner();
- let tls_stream = read_half.unsplit(write_half);
+ let tls_stream = read_half.reunite(write_half);
let addr = tls_stream.get_ref().0.local_addr()?;
let hyper_connection = Http::new()