diff options
author | Luca Casonato <hello@lcas.dev> | 2022-10-26 21:04:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 19:04:27 +0000 |
commit | f4f1f4f0b64030b744cfb43693af321ea8332bf4 (patch) | |
tree | 9d4e1fcf9ea9b92ef5a863fcd449edf8c0c9a834 /ext/net/ops_tls.rs | |
parent | de580cedd24be22dc267d5b92538364ed9998a46 (diff) |
feat(ext/net): reusePort for TCP on Linux (#16398)
Diffstat (limited to 'ext/net/ops_tls.rs')
-rw-r--r-- | ext/net/ops_tls.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/net/ops_tls.rs b/ext/net/ops_tls.rs index b27426894..1e2b54533 100644 --- a/ext/net/ops_tls.rs +++ b/ext/net/ops_tls.rs @@ -990,6 +990,7 @@ pub struct ListenTlsArgs { // TODO(kt3k): Remove this option at v2.0. key_file: Option<String>, alpn_protocols: Option<Vec<String>>, + reuse_port: bool, } #[op] @@ -1001,6 +1002,10 @@ pub fn op_net_listen_tls<NP>( where NP: NetPermissions + 'static, { + if args.reuse_port { + super::check_unstable(state, "Deno.listenTls({ reusePort: true })"); + } + let cert_file = args.cert_file.as_deref(); let key_file = args.key_file.as_deref(); let cert = args.cert.as_deref(); @@ -1061,6 +1066,10 @@ where let socket = Socket::new(domain, Type::STREAM, None)?; #[cfg(not(windows))] socket.set_reuse_address(true)?; + if args.reuse_port { + #[cfg(target_os = "linux")] + socket.set_reuse_port(true)?; + } let socket_addr = socket2::SockAddr::from(bind_addr); socket.bind(&socket_addr)?; socket.listen(128)?; |