1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

chore(ext/http): add env var to disable writev syscall (#19338)

This commit is contained in:
Bartek Iwańczuk 2023-06-01 16:07:26 +02:00 committed by GitHub
parent 1a0445dc6b
commit 5557285689
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<Incoming>;
type Response = hyper1::Response<ResponseBytes>;
static USE_WRITEV: Lazy<bool> = 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<Output = Result<(), AnyError>> + 'static {
let conn = http1::Builder::new()
.keep_alive(true)
.writev(*USE_WRITEV)
.serve_connection(io, svc);
conn.with_upgrades().map_err(AnyError::from)