Skip to main content

SessionSlot

Struct SessionSlot 

Source
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_rx inspectors in new_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 bypasses session_rx entirely.

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

Source

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).

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> SessionSlot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DynClone for T
where T: Clone,

§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows 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) -> R
where R: 'a,

Mutably borrows 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
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows 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
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows 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
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .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
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .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
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more