pub(crate) struct SessionSlot {Show 14 fields
session_tx: MTx<Array<ApplicationDataIn>>,
routing_opts: DestinationRouting,
abort_handles: Arc<Mutex<AbortableList<SessionHandles>>>,
surb_mgmt: Arc<BalancerStateValues>,
surb_estimator: AtomicSurbFlowEstimator,
current_ssa_state: Arc<OnceLock<SessionSsaState>>,
pix_supervisor: Arc<OnceLock<SessionPixSupervisorHandle>>,
pix_egress_gate: Arc<OnceLock<Arc<ServiceGate>>>,
pix_fill: Arc<OnceLock<Arc<PixFillControl>>>,
exit_loss_signal: Arc<OnceLock<Arc<FrameLossSignal>>>,
returned_packets: Arc<AtomicU64>,
cycle_budget: Option<Arc<CycleBudgetReservation>>,
admission_token: Arc<OnceLock<AdmissionToken>>,
raised_surb_target: Arc<AtomicUsize>,
}Fields§
§session_tx: MTx<Array<ApplicationDataIn>>§routing_opts: DestinationRouting§abort_handles: Arc<Mutex<AbortableList<SessionHandles>>>§surb_mgmt: Arc<BalancerStateValues>§surb_estimator: AtomicSurbFlowEstimator§current_ssa_state: Arc<OnceLock<SessionSsaState>>§pix_supervisor: Arc<OnceLock<SessionPixSupervisorHandle>>Handle to this Session’s PIX supervisor, on the Exit side of a PIX-enabled Session.
Populated before the HoprSession is constructed, so the egress adapters below observe a
gate rather than racing its installation. Empty on the Entry side and on non-PIX Sessions —
the Exit is authoritative for the lifecycle, so the Entry runs no supervisor.
pix_egress_gate: Arc<OnceLock<Arc<ServiceGate>>>The egress gate every outgoing data packet of a supervised Session must pass.
Held separately from pix_supervisor because the egress path touches it per packet and has
no use for the rest of the handle.
pix_fill: Arc<OnceLock<Arc<PixFillControl>>>Steers the Exit’s own Exit → Entry keep-alive stream, where the Session has one.
Exit-side, and populated for every PIX Session as well as for any Session with a configured
surb_balance_notify_period — the two producers share one stream, so they share one handle.
Empty on the Entry side, whose keep-alives are driven by its SURB balancer instead, and on an
Exit Session that is neither PIX nor notifying, which originates nothing at all.
A OnceLock for the same reason the two fields above are: the action driver that sets rates
on it is spawned after the slot is published, so it must find the handle rather than race its
installation.
exit_loss_signal: Arc<OnceLock<Arc<FrameLossSignal>>>This Session’s live frame loss signal, where the Exit created one for it.
Exit-side, and set only for a Session that can report at the degraded period — an Exit with a
notification period, a degraded one and frames to lose (Capability::Segmentation). The socket
records into it and the keep-alive driver reads it, each through its own clone. Nothing in
production reads this slot: it is kept so that tests can reach the very signal the driver
watches and inject loss into it, which they cannot do through the socket.
returned_packets: Arc<AtomicU64>Exit → Entry Session packets received on this Session, ever.
Entry-side only; stays zero on the Exit, which is the side that sends them. This includes
both Session data and Start-protocol traffic such as the Exit’s SURB-level keep-alives. Each
packet consumed one return SURB, and a SURB carries at most one PIX share which the Exit can
only decrypt by using it — so this counts shares the Exit has unlocked, measured without
asking it. That is what makes it usable as a deposit gate: see the successor gate in
SessionManager::handle_ssa_request.
Deliberately not surb_estimator.consumed, which increments on
the same event on this side today. That field is documented as an estimate feeding the PID
balancer, and it is only wired when surb_management is enabled; this one decides whether
money is spent and must be neither. Carrying the increment twice is the cheaper mistake: a
receive path that forgets this counter makes the gate stricter, never laxer.
Credited from exactly two places, and both of them have to stay:
- the
session_rxinspectors innew_session, once per Session data packet handed to the reader — one in each of the balanced and unbalanced branches; - the Start-protocol branch of
dispatch_message, which credits every Start-protocol message arriving on an outgoing Session because that traffic bypassessession_rxentirely.
The second is what makes the Exit’s keep-alives count, and the gate depends on it: an Exit
whose application has nothing to say can still complete a funded cycle by keep-alive alone, and
if those packets earned nothing here its successor would be refused as under-served and the
Session would die on CommitmentTimeout with neither side able to name the cause. It is
credited at the dispatch level rather than inside a per-message handler on purpose — the credit
is owed for the SURB the packet consumed, which is true whatever the message turns out to be,
including one this build fails to parse. Adding a second increment inside
handle_keep_alive would double-count it.
cycle_budget: Option<Arc<CycleBudgetReservation>>This Session’s share of the node’s live reconstructor-cycle budget.
Exit-side and PIX-only; None everywhere else, since nothing else holds cycle state. Behind
an Arc so the budget is returned when the last clone of this slot goes: a slot is cloned
into the Session cache and into its SessionSlotGuard, so no single one of them can be
made responsible for the release.
close_session returns it explicitly, which is what makes the release simultaneous with
the closure; the Drop behind the Arc is the backstop for anything that bypasses that
function. Both are safe to run because the release is idempotent.
admission_token: Arc<OnceLock<AdmissionToken>>The SURB-store admission this Session’s commit obtains, threaded to the teardown so its
retire can be matched to the admission it belongs to.
Behind an Arc and empty until commit because the guard — which performs the admit — and
the slot in the sessions cache are two clones of one value: the token has to land in the
cached copy, and commit runs after the slot was inserted. Every teardown reads the token
from the slot it removes, so it travels with the Session however long the teardown is delayed;
empty stays AdmissionToken::NONE, which matches no admission, so a rolled-back Session’s
retire is the no-op the seam’s idempotency is there for.
The same cell is what identifies this slot to the commit that allocated it — see
AdmissionCell.
raised_surb_target: Arc<AtomicUsize>The largest SURB target a BalancerTarget keep-alive has announced for this Session, or
None while none has.
Kept because the Exit answers SessionEstablished before it commits, so the Entry’s ramp can
announce a raised target in that window: the ring is sized at commit, from the target
announced at establishment, and a raise that arrived earlier would otherwise be lost until the
Entry announced it again. The commit applies this figure too, and every later raise widens the
ring on the spot (see SurbAdmissionControl::raise_target).
Implementations§
Source§impl SessionSlot
impl SessionSlot
Sourcefn claim_admission_token(&self) -> AdmissionToken
fn claim_admission_token(&self) -> AdmissionToken
Claims the slot’s admission-token cell on behalf of a teardown and returns what it holds.
Empty means no commit has run yet, and the teardown claims the cell by storing
AdmissionToken::NONE into it. That write is what lets a commit racing this teardown tell
it lost: its own set then fails, and it retires the admission it just made instead of leaving
a ring no teardown will ever remove. Without the claim, a teardown that read the empty cell
would schedule a no-op retire, and a commit landing afterwards would admit a Session that is
already gone — the leak the exit-side SessionEstablished-before-commit ordering makes
reachable. Returns the token a later commit would have stored, or NONE when this teardown
got there first (or the Session was never admitted at all).
Sourcefn peek_admission_token(&self) -> AdmissionToken
fn peek_admission_token(&self) -> AdmissionToken
The token this slot holds, or AdmissionToken::NONE while no commit has run.
Read-only, unlike claim_admission_token: a keep-alive asking
the store to widen this Session’s ring must not claim the cell, or it would initialize it and
make the establishment’s own commit fail its set — retiring the live admission and leaving
the Session’s SURBs unadmitted.
Sourcefn note_raised_surb_target(&self, target: usize)
fn note_raised_surb_target(&self, target: usize)
Records a target announced by a BalancerTarget keep-alive, if it is the largest so far.
Monotone on purpose, matching the ring it widens: the announcement stream is a slew, and the
last value seen is the one the Entry is filling toward. Recorded even before commit has
sized the ring, which is the window the Exit’s SessionEstablished-before-commit ordering
opens; peek_raised_surb_target then lets the commit start
from the largest figure already announced rather than from establishment’s.
Sourcefn peek_raised_surb_target(&self) -> Option<usize>
fn peek_raised_surb_target(&self) -> Option<usize>
The largest target announced since establishment, or None while none has been.
Trait Implementations§
Source§impl Clone for SessionSlot
impl Clone for SessionSlot
Source§fn clone(&self) -> SessionSlot
fn clone(&self) -> SessionSlot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SessionSlot
impl !UnwindSafe for SessionSlot
impl Freeze for SessionSlot
impl Send for SessionSlot
impl Sync for SessionSlot
impl Unpin for SessionSlot
impl UnsafeUnpin for SessionSlot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.