Skip to content

Commit

Permalink
Fix tokio crash
Browse files Browse the repository at this point in the history
Thanks to @Vixea for the extensive testing
  • Loading branch information
zmerp committed Jul 17, 2023
1 parent 0c6e37c commit d56efb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion alvr/sockets/src/stream_socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub fn bind(

super::set_socket_buffers(&socket, send_buffer_bytes, recv_buffer_bytes).ok();

let _tokio_guard = runtime.enter();
TcpListener::from_std(socket.into()).map_err(err!())
}

Expand Down Expand Up @@ -81,7 +82,10 @@ pub fn connect_to_client(

super::set_socket_buffers(&socket, send_buffer_bytes, recv_buffer_bytes).ok();

let socket = TcpStream::from_std(socket.into()).map_err(to_con_e!())?;
let socket = {
let _tokio_guard = runtime.enter();
TcpStream::from_std(socket.into()).map_err(to_con_e!())?
};
socket.set_nodelay(true).map_err(to_con_e!())?;
let socket = Framed::new(socket, Ldc::new());
let (send_socket, receive_socket) = socket.split();
Expand Down
1 change: 1 addition & 0 deletions alvr/sockets/src/stream_socket/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn bind(

super::set_socket_buffers(&socket, send_buffer_bytes, recv_buffer_bytes).ok();

let _tokio_guard = runtime.enter();
UdpSocket::from_std(socket.into()).map_err(err!())
}

Expand Down

0 comments on commit d56efb8

Please sign in to comment.