#[non_exhaustive]pub enum Failure {
Connection,
Exhausted,
Unknown,
}Expand description
What a failed accept(2) means for the listener that saw it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connection
One pending connection died on its way to us: the peer reset it before we dequeued it, a firewall rule dropped it, its handshake timed out.
Ordinary traffic, and never a fault of the listener. The queue entry is
consumed, so the very next accept makes progress and delaying it would only
punish the connections queued behind the dead one, at whatever rate a remote
peer chooses to supply them.
How reachable that is depends on the platform. Linux surfaces a new socket’s
already-pending network errors through accept (which BSD does not, and which
is why the list is as long as it is), but drops a connection reset before
accept from the queue silently rather than reporting ECONNABORTED. So the
simplest flood is louder on BSD than on Linux; the handling is the same either
way.
Exhausted
A resource accept needs is exhausted process-wide or host-wide: the process
fd table (EMFILE), the system-wide one (ENFILE), or kernel memory for the
new socket (ENOBUFS/ENOMEM).
The connection stays queued, so the listener is instantly readable and instantly failing until something outside this loop returns the resource.
Unknown
An errno we don’t recognize. Worth backing off on, never worth claiming a cause for: an unrecognized failure on ordinary traffic could be driven by a remote peer, so escalating on it hands out a remote lever.
Implementations§
Source§impl Failure
impl Failure
Sourcepub const ALL: &'static [Failure]
pub const ALL: &'static [Failure]
Every class, for a caller enumerating Health::failures into a metrics
endpoint.
A slice rather than an array: the length of an array is part of the type, so
[Failure; 3] would make adding a class a breaking change for every caller
that named the type, defeating the #[non_exhaustive] above.
Sourcepub fn classify(err: &Error) -> Self
pub fn classify(err: &Error) -> Self
Classify a failed accept(2).
Unrecognized is Unknown, never Connection:
the default has to be the one that paces, because guessing “per connection” on a
listener-wide failure is the mistake that spins.
Trait Implementations§
impl Copy for Failure
impl Eq for Failure
impl StructuralPartialEq for Failure
Auto Trait Implementations§
impl Freeze for Failure
impl RefUnwindSafe for Failure
impl Send for Failure
impl Sync for Failure
impl Unpin for Failure
impl UnsafeUnpin for Failure
impl UnwindSafe for Failure
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.