Skip to content

Commit

Permalink
fix: Compilation error from nix upgrade
Browse files Browse the repository at this point in the history
`nix::sys::socket::listen` now takes a backlog argument instead of an
`i32`. In the case that `SOMAXCONN` is less than 128, we use that value.

Signed-off-by: Jalil David Salamé Messina <[email protected]>
  • Loading branch information
jalil-salame committed Feb 27, 2024
1 parent a039ef0 commit 197d5fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use nix::{
sys::socket::{
self, bind, connect, getpeername, getsockname, listen, recv, send, shutdown, socket,
sockopt::{ReceiveTimeout, SendTimeout, SocketError},
AddressFamily, GetSockOpt, MsgFlags, SetSockOpt, SockFlag, SockType,
AddressFamily, Backlog, GetSockOpt, MsgFlags, SetSockOpt, SockFlag, SockType,
},
};
use std::mem::size_of;
Expand Down Expand Up @@ -86,7 +86,7 @@ impl VsockListener {
bind(socket.as_raw_fd(), addr)?;

// rust stdlib uses a 128 connection backlog
listen(&socket, 128)?;
listen(&socket, Backlog::new(128).unwrap_or(Backlog::MAXCONN))?;

Ok(Self { socket })
}
Expand Down

0 comments on commit 197d5fc

Please sign in to comment.