This commit is contained in:
Alexey
2026-08-27 00:06:37 +03:00
parent 1b3477a333
commit 14e8d10ad3
34 changed files with 221 additions and 299 deletions
+2 -4
View File
@@ -156,10 +156,8 @@ impl WebSession {
let fits = if control {
bytes <= self.limits.control_bytes_per_session
&& items <= item_reserve
&& pending_bytes
<= self.limits.pending_bytes_per_session.saturating_sub(bytes)
&& pending_items
<= self.limits.pending_items_per_session.saturating_sub(items)
&& pending_bytes <= self.limits.pending_bytes_per_session.saturating_sub(bytes)
&& pending_items <= self.limits.pending_items_per_session.saturating_sub(items)
&& pending_control_bytes
<= self.limits.control_bytes_per_session.saturating_sub(bytes)
&& pending_control_items <= item_reserve.saturating_sub(items)
+1 -2
View File
@@ -5,8 +5,7 @@ use std::sync::Arc;
use arc_swap::ArcSwap;
use crate::config::{
ProxyConfig, WebCarrier, WebLimitsConfig, WebRuntimeProfile, WebSecretMode,
WebTimeoutsConfig,
ProxyConfig, WebCarrier, WebLimitsConfig, WebRuntimeProfile, WebSecretMode, WebTimeoutsConfig,
};
use crate::maestro::generation::test_runtime_generation;
use crate::web::manager::WebProcessRuntime;
+2 -4
View File
@@ -56,8 +56,7 @@ impl WebSession {
&& only_late_frames(&frames)
{
return if self.automatic_carrier
&& state.negotiation_phase
!= super::SessionNegotiationPhase::Committed
&& state.negotiation_phase != super::SessionNegotiationPhase::Committed
{
Err(ManagerError::Backpressure)
} else {
@@ -154,8 +153,7 @@ impl WebSession {
}
}
if applied {
(committed, healthy) =
self.record_uplink_progress_locked(&mut state, progress);
(committed, healthy) = self.record_uplink_progress_locked(&mut state, progress);
}
applied.then_some(sequence).ok_or(ManagerError::Closed)
};
+6 -11
View File
@@ -119,8 +119,7 @@ impl WebSession {
return Err(ManagerError::Closed);
}
let carrier_health_eligible = lane_id != 0
&& state.negotiation_phase
== super::SessionNegotiationPhase::Committed;
&& state.negotiation_phase == super::SessionNegotiationPhase::Committed;
let Some(lane) = state.carrier_lanes.get_mut(&lane_id) else {
return Ok(PollResult {
body: Bytes::new(),
@@ -231,11 +230,7 @@ impl WebSession {
}
}
async fn wait_for_lane_open(
&self,
lane_id: u32,
cursor: u64,
) -> Result<bool, ManagerError> {
async fn wait_for_lane_open(&self, lane_id: u32, cursor: u64) -> Result<bool, ManagerError> {
let wait = {
let mut state = self.state.lock();
if state.closed {
@@ -355,10 +350,10 @@ impl WebSession {
let resident = lane.resident.snapshot();
payload.len() > self.limits.pending_bytes_per_lane
|| lane.pending_bytes.saturating_add(resident.data_bytes)
> self
.limits
.pending_bytes_per_lane
.saturating_sub(payload.len())
> self
.limits
.pending_bytes_per_lane
.saturating_sub(payload.len())
}) {
return false;
}
+6 -8
View File
@@ -6,8 +6,7 @@ use bytes::BytesMut;
use super::*;
use crate::config::{
ProxyConfig, WebCarrier, WebLimitsConfig, WebRuntimeProfile, WebSecretMode,
WebTimeoutsConfig,
ProxyConfig, WebCarrier, WebLimitsConfig, WebRuntimeProfile, WebSecretMode, WebTimeoutsConfig,
};
use crate::maestro::generation::test_runtime_generation;
use crate::web::manager::WebProcessRuntime;
@@ -187,7 +186,9 @@ fn lane_uplink_sequences_are_independent_and_exactly_once() {
{
let mut state = session.state.lock();
for lane_id in [51, 52] {
state.carrier_lanes.insert(lane_id, CarrierLane::new(u64::from(lane_id)));
state
.carrier_lanes
.insert(lane_id, CarrierLane::new(u64::from(lane_id)));
state.closed_streams.insert(lane_id);
}
}
@@ -274,11 +275,8 @@ fn tombstone_eviction_releases_lane_budget_and_accepts_late_frames() {
#[test]
fn automatic_lane_does_not_ack_a_missing_lane_without_real_progress() {
let session = new_session_with_automatic(
WebLimitsConfig::default(),
std::sync::Weak::new(),
true,
);
let session =
new_session_with_automatic(WebLimitsConfig::default(), std::sync::Weak::new(), true);
let late = frame::encode(FrameType::Data, 7, b"late");
assert_eq!(
+2 -12
View File
@@ -138,12 +138,7 @@ impl WebSession {
if let Some(batch) = state.unacked.take() {
batch.lease.detach();
self.release_local_locked(&mut state, batch.data_bytes, batch.data_items, false);
self.release_local_locked(
&mut state,
batch.control_bytes,
batch.control_items,
true,
);
self.release_local_locked(&mut state, batch.control_bytes, batch.control_items, true);
}
let mut lane_data_bytes = 0usize;
let mut lane_data_items = 0usize;
@@ -160,12 +155,7 @@ impl WebSession {
}
}
self.release_local_locked(&mut state, lane_data_bytes, lane_data_items, false);
self.release_local_locked(
&mut state,
lane_control_bytes,
lane_control_items,
true,
);
self.release_local_locked(&mut state, lane_control_bytes, lane_control_items, true);
state.carrier_lanes.clear();
let control_bytes = state.pending_control_bytes;
let control_items = state.pending_control_items;
+2 -3
View File
@@ -93,9 +93,8 @@ impl WebSession {
let now = Instant::now();
let committed = if state.negotiation_phase == SessionNegotiationPhase::Uncommitted {
state.negotiation_phase = SessionNegotiationPhase::Committed;
state.carrier_health_due_at = Some(
now + Duration::from_secs(self.timeouts.carrier_health_secs),
);
state.carrier_health_due_at =
Some(now + Duration::from_secs(self.timeouts.carrier_health_secs));
true
} else {
false
+8 -4
View File
@@ -43,8 +43,10 @@ impl ResidentCounters {
}
fn add(&self, counts: PendingCounts) {
self.data_bytes.fetch_add(counts.data_bytes, Ordering::AcqRel);
self.data_items.fetch_add(counts.data_items, Ordering::AcqRel);
self.data_bytes
.fetch_add(counts.data_bytes, Ordering::AcqRel);
self.data_items
.fetch_add(counts.data_items, Ordering::AcqRel);
self.control_bytes
.fetch_add(counts.control_bytes, Ordering::AcqRel);
self.control_items
@@ -52,8 +54,10 @@ impl ResidentCounters {
}
fn remove(&self, counts: PendingCounts) {
self.data_bytes.fetch_sub(counts.data_bytes, Ordering::AcqRel);
self.data_items.fetch_sub(counts.data_items, Ordering::AcqRel);
self.data_bytes
.fetch_sub(counts.data_bytes, Ordering::AcqRel);
self.data_items
.fetch_sub(counts.data_items, Ordering::AcqRel);
self.control_bytes
.fetch_sub(counts.control_bytes, Ordering::AcqRel);
self.control_items
+5 -3
View File
@@ -139,8 +139,7 @@ impl WebSession {
} else {
state.last_up_sequence = sequence;
state.last_up_digest = digest;
(committed, healthy) =
self.record_uplink_progress_locked(&mut state, progress);
(committed, healthy) = self.record_uplink_progress_locked(&mut state, progress);
Ok((sequence, progress.any()))
}
};
@@ -532,7 +531,10 @@ mod tests {
let session = session_with_automatic(true);
let body = frame::encode(FrameType::Pong, 0, &[]);
assert_eq!(session.process_up(1, &body), Err(ManagerError::Backpressure));
assert_eq!(
session.process_up(1, &body),
Err(ManagerError::Backpressure)
);
assert!(!session.is_carrier_committed());
assert!(!session.state.lock().closed);
}
+1 -2
View File
@@ -273,8 +273,7 @@ impl WebSession {
}
state.last_activity = Instant::now();
if applied {
(committed, healthy) =
self.record_uplink_progress_locked(&mut state, progress);
(committed, healthy) = self.record_uplink_progress_locked(&mut state, progress);
}
applied
.then_some(progress.any())