Skip to content

Commit

Permalink
use default backlog if the backlog isn't initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Oct 1, 2024
1 parent b5c31cd commit 208b7f0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/fd/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub const SHUT_RD: i32 = 0;
pub const SHUT_WR: i32 = 1;
/// further sends and receives will be disallowed
pub const SHUT_RDWR: i32 = 2;
/// The default queue size for incoming connections
pub const DEFAULT_BACKLOG: i32 = 128;

fn get_ephemeral_port() -> u16 {
static LOCAL_ENDPOINT: AtomicU16 = AtomicU16::new(49152);
Expand Down Expand Up @@ -294,6 +296,10 @@ impl Socket {
}

async fn accept(&mut self) -> io::Result<(Socket, Endpoint)> {
if !self.is_listen {
self.listen(DEFAULT_BACKLOG).await?;
}

future::poll_fn(|cx| {
self.with(|socket| {
if socket.is_active() {
Expand Down

0 comments on commit 208b7f0

Please sign in to comment.