From 5557285689b65e9ee7574050adeda79f3572ea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Jun 2023 16:07:26 +0200 Subject: [PATCH] chore(ext/http): add env var to disable writev syscall (#19338) --- ext/http/http_next.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index 7edffed655..7a02757c00 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -53,6 +53,7 @@ use hyper1::service::service_fn; use hyper1::service::HttpService; use hyper1::StatusCode; +use once_cell::sync::Lazy; use pin_project::pin_project; use pin_project::pinned_drop; use std::borrow::Cow; @@ -68,6 +69,16 @@ use tokio::io::AsyncWriteExt; type Request = hyper1::Request; type Response = hyper1::Response; +static USE_WRITEV: Lazy = Lazy::new(|| { + let disable_writev = std::env::var("DENO_HYPER_USE_WRITEV").ok(); + + if let Some(val) = disable_writev { + return val != "0"; + } + + true +}); + /// All HTTP/2 connections start with this byte string. /// /// In HTTP/2, each endpoint is required to send a connection preface as a final confirmation @@ -597,6 +608,7 @@ fn serve_http11_unconditional( ) -> impl Future> + 'static { let conn = http1::Builder::new() .keep_alive(true) + .writev(*USE_WRITEV) .serve_connection(io, svc); conn.with_upgrades().map_err(AnyError::from)