-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add with_backlog
functionality to TcpListener
and UnixListener
#94407
Conversation
Also added TcpListener::DEFAULT_BACKLOG to document the default backlog (currently 128).
…h_backlog Also added UnixListener::DEFAULT_BACKLOG
…nts where appropriate
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. Please see the contribution instructions for more information. |
library/std/src/net/tcp.rs
Outdated
/// The listener will have a backlog given by | ||
/// [`TcpListener::DEFAULT_BACKLOG`]. See the documentation for | ||
/// [`TcpListener::bind_with_backlog`] for further information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The listener will have a backlog given by | |
/// [`TcpListener::DEFAULT_BACKLOG`]. See the documentation for | |
/// [`TcpListener::bind_with_backlog`] for further information. | |
/// The listener will have a backlog of 128. See the documentation | |
/// of [`TcpListener::bind_with_backlog`] for further information. |
library/std/src/net/tcp.rs
Outdated
/// [`TcpListener::accept`]. The backlog argument overrides the default | ||
/// specified by [`TcpListener::DEFAULT_BACKLOG`]; that default is | ||
/// reasonable for most use cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// [`TcpListener::accept`]. The backlog argument overrides the default | |
/// specified by [`TcpListener::DEFAULT_BACKLOG`]; that default is | |
/// reasonable for most use cases. | |
/// [`TcpListener::accept`]. The backlog argument overrides the default | |
/// backlog used by [`TcpListener::bind`]; that default works reasonably | |
/// for most use cases. |
library/std/src/net/tcp.rs
Outdated
/// Default "backlog" for [`TcpListener::bind`]. See | ||
/// [`TcpListener::bind_with_backlog`] for an explanation of backlog | ||
/// values. | ||
#[unstable(feature = "bind_with_backlog", issue = "94406")] | ||
pub const DEFAULT_BACKLOG: usize = 128; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Default "backlog" for [`TcpListener::bind`]. See | |
/// [`TcpListener::bind_with_backlog`] for an explanation of backlog | |
/// values. | |
#[unstable(feature = "bind_with_backlog", issue = "94406")] | |
pub const DEFAULT_BACKLOG: usize = 128; |
I think, rather than exposing this backlog as a constant, we can just document it. If people want to override it they can call bind_with_backlog
; if they want to use the default they can call bind
; if they want to have a default value for some configurable backlog parameter, they can determine an appropriate default themselves with our documentation for inspiration.
That said, this should absolutely be a const
in this module, I just don't think it should be a pub const
.
Have unpublished |
@bors r+ |
📌 Commit b98c009 has been approved by |
…=joshtriplett Add `with_backlog` functionality to `TcpListener` and `UnixListener` Adds * `std::net::TcpListener::DEFAULT_BACKLOG` * `std::net::TcpListener::bind_with_backlog` * `std::os::unix::net::UnixListener::DEFAULT_BACKLOG` * `std::os::unix::net::UnixListener::bind_with_backlog` * `std::os::unix::net::UnixListener::bind_addr_with_backlog` Closes rust-lang#94406
failed in rollup on wasm |
@bors r- |
@joshtriplett @Dylan-DPC Looks like I forgot a wasm stub somehow. Fixed. |
Actually, looks like I forgot a bunch more stuff. Pls hold until I fix the rest of them. |
What to do with platforms like sgx, sgx_fortanix and hermit that apparently support |
Ping from triage: Can you please post the status of this PR? You can close it as inactive. |
Sure, let's call it inactive for now. I'll try again once I've sorted some stuff. |
Adds
std::net::TcpListener::DEFAULT_BACKLOG
std::net::TcpListener::bind_with_backlog
std::os::unix::net::UnixListener::DEFAULT_BACKLOG
std::os::unix::net::UnixListener::bind_with_backlog
std::os::unix::net::UnixListener::bind_addr_with_backlog
Closes #94406