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

replace block_on in net interfaces (#4796)

This commit is contained in:
Bartek Iwańczuk 2020-04-17 18:45:34 +02:00 committed by GitHub
parent 260084ccbf
commit 41f836dc91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -460,7 +460,8 @@ fn listen_tcp(
addr: SocketAddr,
) -> Result<(u32, SocketAddr), OpError> {
let mut state = state.borrow_mut();
let listener = futures::executor::block_on(TcpListener::bind(&addr))?;
let std_listener = std::net::TcpListener::bind(&addr)?;
let listener = TcpListener::from_std(std_listener)?;
let local_addr = listener.local_addr()?;
let listener_resource = TcpListenerResource {
listener,
@ -479,7 +480,8 @@ fn listen_udp(
addr: SocketAddr,
) -> Result<(u32, SocketAddr), OpError> {
let mut state = state.borrow_mut();
let socket = futures::executor::block_on(UdpSocket::bind(&addr))?;
let std_socket = std::net::UdpSocket::bind(&addr)?;
let socket = UdpSocket::from_std(std_socket)?;
let local_addr = socket.local_addr()?;
let socket_resource = UdpSocketResource { socket };
let rid = state

View file

@ -238,7 +238,8 @@ fn op_listen_tls(
.expect("invalid key or certificate");
let tls_acceptor = TlsAcceptor::from(Arc::new(config));
let addr = resolve_addr(&args.hostname, args.port)?;
let listener = futures::executor::block_on(TcpListener::bind(&addr))?;
let std_listener = std::net::TcpListener::bind(&addr)?;
let listener = TcpListener::from_std(std_listener)?;
let local_addr = listener.local_addr()?;
let tls_listener_resource = TlsListenerResource {
listener,