1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! The spawn-budget poll loop. The liveness classification it calls lives in
//! `crate::uds::probe` since #5182 — `bind_singleton_hardened` needs the same
//! answer and is not behind this feature. See there for why ECONNREFUSED is not
//! simply "no listener", and for the accept-promptly REQUIREMENT that fact
//! places on every supervised service.
//!
//! Test: `wait_for_socket_gives_up_within_the_spawn_budget`,
//! `wait_for_socket_returns_once_the_socket_binds`.
use Path;
use cratesocket_is_serving;
use ServiceTimeouts;
/// Poll the socket with exponential backoff until it accepts a connection or
/// the service's spawn budget elapses.
///
/// Why: a freshly-spawned child takes an unknown time to bind — a few ms for a
/// service with nothing to load, tens of seconds for one that loads a model.
/// Polling from a short initial interval and doubling gives sub-50 ms detection
/// on the fast case without hammering the kernel on the slow one.
/// What: loops [`socket_is_serving`] until success or until the cumulative wait
/// exceeds `timeouts.spawn_probe`. Never sleeps past the deadline.
/// Test: `wait_for_socket_gives_up_within_the_spawn_budget`,
/// `wait_for_socket_returns_once_the_socket_binds`.
pub async