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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The options every socket the server accepts carries before it is handed
//! onward.
use ;
use Duration;
/// How long an accepted connection stays silent before the kernel probes its
/// peer. Probing is the kernel's, sent only on a silent connection: one empty
/// segment per idle connection per half minute, and nothing of ours wakes.
pub const KEEPALIVE_IDLE: Duration = from_secs;
/// The gap between unanswered probes.
pub const KEEPALIVE_INTERVAL: Duration = from_secs;
/// Unanswered probes before the kernel ends the connection: five ride out a
/// brief network drop, and a peer that is gone is found within 80 seconds
/// (30 + 5 x 10), when the connection's close releases any agent seat it
/// held (`agents::runtime::connection_closed`).
pub const KEEPALIVE_RETRIES: u32 = 5;
/// Prepares a freshly accepted socket before it is handed onward.
///
/// Every socket the server ACCEPTS carries `TCP_NODELAY`, the accept-side twin
/// of the client sockets in liminal-sdk, which have always set it. Nagle holds a
/// frame's trailing partial segment until the peer's delayed ACK arrives, so
/// without this any server-initiated write spanning more than one segment stalls
/// ~40ms — and server push is a core protocol primitive, not an edge case.
///
/// Every accept loop in the server routes its socket through this one function
/// (main wire protocol, sibling WebSocket, health endpoint), so the option is
/// pinned in one place rather than re-derived per listener. The shed paths are
/// deliberately NOT prepared: those sockets are dropped unwritten.
///
/// A failure here degrades latency but does not break the connection, so the
/// socket is still served — the accept loops treat per-connection setup trouble
/// as loggable, never as a reason to drop a peer or kill the loop.