From 8825cf0838553fd8ddb14a357d0176e3c2074e2b Mon Sep 17 00:00:00 2001 From: ospab Date: Sat, 30 May 2026 22:21:12 +0300 Subject: [PATCH] fix: resolve deadlock, multiplexing backpressure, and LTE fragmentation issues --- ostp-client/src/bridge.rs | 4 ++-- ostp-client/src/config.rs | 2 +- ostp-core/src/protocol.rs | 10 +++++----- .../kotlin/com/ospab/ostp_client/OstpVpnService.kt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ostp-client/src/bridge.rs b/ostp-client/src/bridge.rs index 748c586..30c25e9 100644 --- a/ostp-client/src/bridge.rs +++ b/ostp-client/src/bridge.rs @@ -617,8 +617,8 @@ impl Bridge { } } proxy_ev = proxy_rx.recv(), if self.running && sessions_opt.as_ref().map(|s| { - // Backpressure: suspend proxy reads when ARQ window is saturated - s.iter().all(|ses| ses.machine.in_flight_count() < ses.machine.cwnd_packets().clamp(16, 16384)) + // Backpressure: suspend proxy reads when ARQ window is saturated across ALL sessions + s.iter().any(|ses| ses.machine.in_flight_count() < ses.machine.cwnd_packets().clamp(16, 16384)) }).unwrap_or(true) => { if let Some(ev) = proxy_ev { if let Some(sessions) = sessions_opt.as_mut() { diff --git a/ostp-client/src/config.rs b/ostp-client/src/config.rs index 3bab864..e9db5df 100644 --- a/ostp-client/src/config.rs +++ b/ostp-client/src/config.rs @@ -58,7 +58,7 @@ pub struct OstpConfig { fn default_keepalive() -> u64 { 5 } -fn default_mtu() -> usize { 1500 } +fn default_mtu() -> usize { 1140 } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LocalProxyConfig { diff --git a/ostp-core/src/protocol.rs b/ostp-core/src/protocol.rs index 463186b..5dc6b0b 100644 --- a/ostp-core/src/protocol.rs +++ b/ostp-core/src/protocol.rs @@ -557,9 +557,6 @@ impl ProtocolMachine { // Limit retransmits per tick to prevent bandwidth saturation let mut retransmit_budget: usize = self.cc.retransmit_budget(); for frame in self.sent_history.iter_mut() { - if retransmit_budget == 0 { - break; - } if !frame.is_retransmittable { continue; } @@ -571,8 +568,11 @@ impl ProtocolMachine { if now.duration_since(frame.last_sent) >= effective_rto { frame.last_sent = now; frame.retries = frame.retries.saturating_add(1); - actions.push(ProtocolAction::SendDatagram(frame.bytes.clone())); - retransmit_budget -= 1; + + if retransmit_budget > 0 { + actions.push(ProtocolAction::SendDatagram(frame.bytes.clone())); + retransmit_budget -= 1; + } } } diff --git a/ostp-flutter/android/app/src/main/kotlin/com/ospab/ostp_client/OstpVpnService.kt b/ostp-flutter/android/app/src/main/kotlin/com/ospab/ostp_client/OstpVpnService.kt index 2f774f3..09cbdf1 100644 --- a/ostp-flutter/android/app/src/main/kotlin/com/ospab/ostp_client/OstpVpnService.kt +++ b/ostp-flutter/android/app/src/main/kotlin/com/ospab/ostp_client/OstpVpnService.kt @@ -161,7 +161,7 @@ class OstpVpnService : VpnService() { .addRoute("0.0.0.0", 0) .addRoute("::", 0) .addDnsServer(dnsServer) - .setMtu(json.optJSONObject("ostp")?.optInt("mtu", 1280) ?: 1280) + .setMtu(json.optJSONObject("ostp")?.optInt("mtu", 1140) ?: 1140) try { builder.addDnsServer("8.8.8.8") } catch (e: Throwable) {}