Expand description
What an accept loop does when accept fails.
Almost every failure is temporary, and nothing about the listener is
wrong: the process is out of descriptors or buffers (EMFILE, ENFILE,
ENOBUFS, ENOMEM), or a peer went away between the kernel completing its
handshake and the call returning it (ECONNABORTED, and on Linux the
network errors accept(2) says to treat like EAGAIN). Stopping on those
would turn a connection burst into dropping every live session, so the loop
retries, backing off so an exhausted descriptor table does not spin a core.
A few errors mean the listening socket itself is unusable (EBADF,
EINVAL, ENOTSOCK, EFAULT). Retrying those would loop forever without
ever accepting again, so they are fatal: the caller stops accepting, and the
orchestrator restarts a working process.
Nothing here logs. A persistent failure would otherwise produce one line per
attempt, so AcceptErrors says when a summary is due and the application
reports it through its own events or logs.
A temporary failure that never clears, such as a descriptor table that
stays full, would otherwise leave a process that refuses every connection
while its probes report it healthy. AcceptHealth turns that into a
readiness failure, so a load balancer stops sending new connections. It
never fails liveness: a restart would cut every live session, and the usual
cure is those sessions ending and freeing descriptors.
Structs§
- Accept
Errors - Failure bookkeeping for one listener’s accept loop.
- Accept
Health - Whether one listener has been failing to accept for long enough that its process should stop receiving new connections.
Enums§
- Next
- What to do after one failed
accept.
Constants§
- INITIAL_
BACKOFF - First pause after a failure. Short, because the usual cause is one aborted
connection and the next
acceptsucceeds. - MAXIMUM_
BACKOFF - Longest pause. Bounds how long a recovered listener can sit idle, and keeps a persistent failure at one wakeup per second.
- PERSISTENT_
FAILURE - How long
acceptmust keep failing beforeAcceptHealthreports it. - QUIET_
AFTER_ FAILURE - Without a failure for this long, a run of failures has ended.
- REPORT_
INTERVAL - How often a persistent failure is reported after its first occurrence.
Functions§
- is_
fatal - Whether an
accepterror leaves the listener unusable.