Skip to main content

Module shutdown

Module shutdown 

Source
Expand description

The shutdown signal, from the process down to each connection.

Graceful shutdown of a proxy is not “stop the process”: every open tunnel is somebody’s TCP connection or UDP flow, and dropping them all at once is visible to the user as a burst of broken pages and dead calls. RFC 9114 §5.2 provides the polite version, and the sequence the server implements is:

  1. stop accepting new QUIC connections;
  2. send a GOAWAY on every live HTTP/3 connection, which tells the client to take its new requests elsewhere while the ones in flight finish;
  3. wait for the tunnels to end on their own, up to server.shutdown_grace;
  4. close the endpoint regardless, so a stuck tunnel cannot hold the process open forever;
  5. stop the runtime, waiting no longer than blocking_grace for the blocking tasks that are still running.

This module is mostly the signal: a one-way latch that many tasks can wait on and that never un-fires, so a task arriving late still observes it. Steps 1, 3 and 4 live in crate::quic; step 2 lives in crate::conn; step 5 is stop_runtime here, called by the binary once the runtime’s own work is done.

Structs§

Shutdown
Observes the shutdown signal.
Trigger
Fires the shutdown signal. Cheap to clone; any clone can fire it.

Constants§

EXIT_SLACK
The margin blocking_grace adds on top of the shutdown budget.

Functions§

blocking_grace
How long the blocking pool gets once the runtime’s own work is over.
channel
Creates a fresh signal, unfired.
stop_runtime
Stops runtime, waiting at most blocking_grace for its blocking tasks.