document that we do not support EPOLLONESHOT and advise the use of EPOLLET, and add debug assert to check for EPOLLONESHOT

This commit is contained in:
Noah Kennedy
2023-10-23 09:45:46 -05:00
parent 0f9f229359
commit 54c3096b24
4 changed files with 26 additions and 6 deletions
+7 -2
View File
@@ -247,8 +247,13 @@ impl<T: AsRawFd> AsyncFd<T> {
///
/// These flags replace any epoll flags would normally set when registering the fd.
///
/// **Note**: This is an [unstable API][unstable]. The public API of this may break in 1.x
/// releases.
/// # Note
/// This API does not support the use of `EPOLLONESHOT`.
/// Users are strongly advised to use `EPOLLET` to prevent the tokio IO driver from receiving
/// spurious wakes.
///
/// # Stability
/// This is an [unstable API][unstable]. The public API of this may break in 1.x releases.
/// See [the documentation on unstable features][unstable] for details.
///
/// [unstable]: crate#unstable-features
+7 -2
View File
@@ -244,8 +244,13 @@ impl TcpListener {
///
/// These flags replace any epoll flags would normally set when registering the fd.
///
/// **Note**: This is an [unstable API][unstable]. The public API of this may break in 1.x
/// releases.
/// # Note
/// This API does not support the use of `EPOLLONESHOT`.
/// Users are strongly advised to use `EPOLLET` to prevent the tokio IO driver from receiving
/// spurious wakes.
///
/// # Stability
/// This is an [unstable API][unstable]. The public API of this may break in 1.x releases.
/// See [the documentation on unstable features][unstable] for details.
///
/// [unstable]: crate#unstable-features
+7 -2
View File
@@ -118,8 +118,13 @@ impl UnixListener {
///
/// These flags replace any epoll flags would normally set when registering the fd.
///
/// **Note**: This is an [unstable API][unstable]. The public API of this may break in 1.x
/// releases.
/// # Note
/// This API does not support the use of `EPOLLONESHOT`.
/// Users are strongly advised to use `EPOLLET` to prevent the tokio IO driver from receiving
/// spurious wakes.
///
/// # Stability
/// This is an [unstable API][unstable]. The public API of this may break in 1.x releases.
/// See [the documentation on unstable features][unstable] for details.
///
/// [unstable]: crate#unstable-features
+5
View File
@@ -95,6 +95,11 @@ impl Registration {
flags: u32,
handle: scheduler::Handle,
) -> io::Result<Registration> {
debug_assert!(
(flags & libc::EPOLLONESHOT as u32) == 0,
"Tokio does not support using EPOLLONESHOT in user-specified epoll flags"
);
let shared = handle.driver().io().add_source_raw(io, flags)?;
Ok(Registration { handle, shared })