Expand description
Reusable per-user-session singleton bind for a v2 local-socket listener.
Extracted from running-process-broker-v2’s main() (soldr#2361 Phase 2
prep) so any consumer that wants to run v2 broker-server logic — the
scaffold binary in this crate, or soldr’s own embedded broker role —
shares one tested implementation of “bind a name exactly once per user
session, refuse a second bind instead of racing it” rather than each
reimplementing the bind/singleton/stale-socket-cleanup dance.
The stale-socket-cleanup subtlety here is load-bearing: see
bind_singleton’s docs and running-process#899 for the concurrency bug
this module’s shape specifically avoids.
Enums§
- Bind
Singleton Error - Why
bind_singletonrefused to bind.
Functions§
- bind_
singleton - Bind
socket_pathas a v2 local-socket listener, enforcing exactly-one-bind-per-name (the per-user-session singleton property). - bind_
singleton_ with - Bind a caller-owned listener with the same singleton and serialized stale
recovery contract as
bind_singleton. - is_
already_ bound_ error - Classify a
Listener::binderror as “another process is already bound at this name” vs any other bind failure. - resolve_
path_ scoped_ socket_ path - Resolve an install-path-scoped broker name without adding user identity.
- resolve_
socket_ path - Resolve the bare pipe/socket name into a full, platform-specific bind
path:
\\.\pipe\<bare_name>on Windows, or a file under a per-user runtime directory on Unix (macOS additionally hashes the leaf to fitsun_path’s 104-byte limit). - unix_
socket_ path_ is_ stale - Source-compatible stale-endpoint helper for filesystem-backed transports.
Tells a genuinely orphaned socket path (left behind by a process that
exited without cleaning up) apart from a path where a live
peer is listening right now — the two look identical to
bind(AddrInUseeither way). A connect probe distinguishes them: nothing is listening if the connect itself fails to even reach a peer (ConnectionRefused— the classic “orphaned socket file, no listener” signal — orNotFound); any other outcome, including a successful connect, means treat the path as live and leave it alone. Non-filesystem transports returnfalsebecause they leave no endpoint file to retire. - wrap_
socket_ name - Build an
interprocessNamefrom a resolved socket path (seeresolve_socket_path).