diff options
author | Luca Casonato <hello@lcas.dev> | 2022-10-24 00:45:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 00:45:45 +0200 |
commit | 38213f1142200e9184d1c5ae1e25ff781248362a (patch) | |
tree | df73b82893501016251d4e0f845a2dfab6b500f4 /ext/net/ops_unix.rs | |
parent | 0e1167d12d116be7ba1855252b5ca4d668bf3472 (diff) |
fix(ext/net): don't remove sockets on unix listen (#16394)
When listening on a UNIX socket path, Deno currently tries to unlink
this path prior to actually listening. The implementation of this
behaviour is VERY racy, involves 2 additional syscalls, and does not
match the behaviour of any other runtime (Node.js, Go, Rust, etc).
This commit removes this behaviour. If a user wants to listen on an
existing socket, they must now unlink the file themselves prior to
listening.
This change in behaviour only impacts --unstable APIs, so it is not
a breaking change.
Diffstat (limited to 'ext/net/ops_unix.rs')
-rw-r--r-- | ext/net/ops_unix.rs | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/ext/net/ops_unix.rs b/ext/net/ops_unix.rs index c47102400..181dcacec 100644 --- a/ext/net/ops_unix.rs +++ b/ext/net/ops_unix.rs @@ -20,7 +20,6 @@ use serde::Deserialize; use serde::Serialize; use std::borrow::Cow; use std::cell::RefCell; -use std::fs::remove_file; use std::path::Path; use std::rc::Rc; use tokio::net::UnixDatagram; @@ -143,9 +142,6 @@ pub fn listen_unix( state: &mut OpState, addr: &Path, ) -> Result<(u32, tokio::net::unix::SocketAddr), AnyError> { - if addr.exists() { - remove_file(&addr)?; - } let listener = UnixListener::bind(&addr)?; let local_addr = listener.local_addr()?; let listener_resource = UnixListenerResource { @@ -161,9 +157,6 @@ pub fn listen_unix_packet( state: &mut OpState, addr: &Path, ) -> Result<(u32, tokio::net::unix::SocketAddr), AnyError> { - if addr.exists() { - remove_file(&addr)?; - } let socket = UnixDatagram::bind(&addr)?; let local_addr = socket.local_addr()?; let datagram_resource = UnixDatagramResource { |