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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Phase 3 broker → daemon SESSION relay (soldr#2365).
//!
//! The broker's **full-proxy** of a compile session — it stays in the middle and
//! relays every byte between the client and the daemon's SESSION backend
//! endpoint ([`crate::daemon::session_endpoint`]), rather than handing the
//! connection off and stepping out. The client speaks the SESSION wire
//! end-to-end; the broker is transparent to it. Hello / routing / token
//! negotiation runs *before* this and selects which daemon endpoint to dial.
//!
//! [`relay_local_socket_session`] is the production transport. Linux moves each
//! direction through one bounded nonblocking kernel pipe with `splice(2)`;
//! Windows and macOS retain Tokio's buffered relay. [`relay_session`] remains
//! the generic buffered reference and pre-transfer fallback.
use crate;
pub use IntoAsyncStream as IntoRelayAsyncStream;
/// Relay an arbitrary async client's SESSION connection with bounded userspace
/// buffers.
///
/// This is the portable reference implementation and the Linux fallback when
/// raw-descriptor preparation fails before any payload byte moves. Production
/// local-socket accept loops should call [`relay_local_socket_session`] so Linux
/// can use its measured splice path.
///
/// # Errors
///
/// Fails if the daemon endpoint cannot be dialed, or on a fatal transport error
/// during the relay.
pub async
/// Relay a production `interprocess` SESSION connection to its selected daemon.
///
/// The broker does not parse the SESSION wire: `SessionStart`, stdio, and
/// `SessionExit` remain byte-transparent. Linux uses `splice(2)` after both
/// directions have acquired every descriptor and pipe they need. If that
/// preparation fails, the untouched streams fall back to buffered I/O. A fatal
/// error after the first splice is returned rather than replaying bytes.
/// Windows and macOS always use the buffered implementation.
///
/// # Errors
///
/// Fails if the daemon endpoint cannot be dialed, or on a fatal transport error
/// during the relay.
pub async
// The relay's e2e test dials a real daemon SESSION endpoint
// (`serve_session_endpoint`), which only exists under `daemon`; the relay
// module itself needs only `client-async`.