@@ -173,53 +173,14 @@ pub(crate) mod pipeline_debug {
173173 } )
174174 }
175175
176- pub fn push_event ( msg : String ) {
177- if let Ok ( mut g) = state ( ) . events . lock ( ) {
178- if g. len ( ) >= EVENT_CAP { g. pop_front ( ) ; }
179- g. push_back ( msg) ;
180- }
181- }
182-
183- pub fn set_limits ( max_elev : u64 , max_batches : u64 ) {
184- state ( ) . max_elevated . store ( max_elev, Ordering :: Relaxed ) ;
185- state ( ) . max_batch_slots . store ( max_batches, Ordering :: Relaxed ) ;
186- }
187-
188- pub fn set_elevated ( n : u64 ) {
189- state ( ) . elevated . store ( n, Ordering :: Relaxed ) ;
190- }
191-
192- pub fn batch_acquire ( ) {
193- state ( ) . active_batches . fetch_add ( 1 , Ordering :: Relaxed ) ;
194- }
195-
196- pub fn batch_release ( ) {
197- state ( ) . active_batches . fetch_sub ( 1 , Ordering :: Relaxed ) ;
198- }
199-
200- pub fn session_start ( sid : & str ) {
201- state ( ) . active_sessions . fetch_add ( 1 , Ordering :: Relaxed ) ;
202- if let Ok ( mut g) = state ( ) . sessions . lock ( ) {
203- g. insert ( sid[ ..sid. len ( ) . min ( 8 ) ] . to_string ( ) , SessionInfo { depth : 2 , inflight : 0 , elevated : false } ) ;
204- }
205- }
206-
207- pub fn session_end ( sid : & str ) {
208- state ( ) . active_sessions . fetch_sub ( 1 , Ordering :: Relaxed ) ;
209- if let Ok ( mut g) = state ( ) . sessions . lock ( ) {
210- g. remove ( & sid[ ..sid. len ( ) . min ( 8 ) ] ) ;
211- }
212- }
213-
214- pub fn session_update ( sid : & str , depth : usize , inflight : usize , elevated : bool ) {
215- if let Ok ( mut g) = state ( ) . sessions . lock ( ) {
216- if let Some ( info) = g. get_mut ( & sid[ ..sid. len ( ) . min ( 8 ) ] ) {
217- info. depth = depth;
218- info. inflight = inflight;
219- info. elevated = elevated;
220- }
221- }
222- }
176+ pub fn push_event ( _msg : String ) { }
177+ pub fn set_limits ( _max_elev : u64 , _max_batches : u64 ) { }
178+ pub fn set_elevated ( _n : u64 ) { }
179+ pub fn batch_acquire ( ) { }
180+ pub fn batch_release ( ) { }
181+ pub fn session_start ( _sid : & str ) { }
182+ pub fn session_end ( _sid : & str ) { }
183+ pub fn session_update ( _sid : & str , _depth : usize , _inflight : usize , _elevated : bool ) { }
223184
224185 pub fn to_json ( ) -> String {
225186 let s = state ( ) ;
@@ -362,7 +323,7 @@ struct PendingOp {
362323}
363324
364325pub struct TunnelMux {
365- tx : mpsc:: Sender < MuxMsg > ,
326+ tx : mpsc:: UnboundedSender < MuxMsg > ,
366327 /// Set to `true` after the first time the tunnel-node rejects
367328 /// `connect_data` as unsupported. Subsequent sessions skip the
368329 /// optimistic path entirely and go straight to plain connect + data.
@@ -485,7 +446,7 @@ impl TunnelMux {
485446 MAX_ELEVATED_PER_DEPLOYMENT * unique_n as u64 ,
486447 ( CONCURRENCY_PER_DEPLOYMENT * unique_n) as u64 ,
487448 ) ;
488- let ( tx, rx) = mpsc:: channel ( 512 ) ;
449+ let ( tx, rx) = mpsc:: unbounded_channel ( ) ;
489450 tokio:: spawn ( mux_loop ( rx, fronter, step, max) ) ;
490451 Arc :: new ( Self {
491452 tx,
@@ -513,8 +474,12 @@ impl TunnelMux {
513474 self . reply_timeout
514475 }
515476
477+ fn send_sync ( & self , msg : MuxMsg ) {
478+ let _ = self . tx . send ( msg) ;
479+ }
480+
516481 async fn send ( & self , msg : MuxMsg ) {
517- let _ = self . tx . send ( msg) . await ;
482+ let _ = self . tx . send ( msg) ;
518483 }
519484
520485 pub async fn udp_open (
@@ -775,7 +740,7 @@ impl TunnelMux {
775740 }
776741}
777742
778- async fn mux_loop ( mut rx : mpsc:: Receiver < MuxMsg > , fronter : Arc < DomainFronter > , coalesce_step_ms : u64 , coalesce_max_ms : u64 ) {
743+ async fn mux_loop ( mut rx : mpsc:: UnboundedReceiver < MuxMsg > , fronter : Arc < DomainFronter > , coalesce_step_ms : u64 , coalesce_max_ms : u64 ) {
779744 let coalesce_step = Duration :: from_millis ( coalesce_step_ms) ;
780745 let coalesce_max = Duration :: from_millis ( coalesce_max_ms) ;
781746 // One semaphore per deployment ID, each allowing 30 concurrent requests.
@@ -1137,6 +1102,10 @@ async fn fire_batch(
11371102 if let Some ( resp) = batch_resp. r . get ( idx) {
11381103 let _ = reply. send ( Ok ( ( resp. clone ( ) , script_id. clone ( ) ) ) ) ;
11391104 } else {
1105+ tracing:: error!(
1106+ "batch response mismatch: idx={} but r.len()={} (sent {} ops) from script {}" ,
1107+ idx, batch_resp. r. len( ) , n_ops, sid_short,
1108+ ) ;
11401109 let _ = reply. send ( Err ( format ! (
11411110 "missing response in batch from script {}" ,
11421111 sid_short
@@ -1547,7 +1516,7 @@ async fn upload_task(
15471516 }
15481517 Ok ( Ok ( more_n) ) => {
15491518 data. extend_from_slice ( & buf[ ..more_n] ) ;
1550- // Extend window if we hit 32KB threshold
1519+ // Extend window if we hit 8KB threshold
15511520 if !extended && data. len ( ) >= 8 * 1024 {
15521521 deadline = tokio:: time:: Instant :: now ( ) + Duration :: from_secs ( 1 ) ;
15531522 extended = true ;
@@ -2309,16 +2278,16 @@ mod tests {
23092278 /// Build a TunnelMux whose send channel is exposed to the test rather
23102279 /// than wired to a real DomainFronter. Lets tests assert what messages
23112280 /// the client would emit without needing network or apps_script.
2312- fn mux_for_test ( ) -> ( Arc < TunnelMux > , mpsc:: Receiver < MuxMsg > ) {
2281+ fn mux_for_test ( ) -> ( Arc < TunnelMux > , mpsc:: UnboundedReceiver < MuxMsg > ) {
23132282 mux_for_test_with ( 2 )
23142283 }
23152284
23162285 /// Build a TunnelMux for tests with a specific deployment count. The
23172286 /// per-deployment legacy state's aggregate gate (`all_servers_legacy`)
23182287 /// requires `legacy_deployments.len() == num_scripts`, so tests that
23192288 /// exercise that gate need to control how many "deployments" exist.
2320- fn mux_for_test_with ( num_scripts : usize ) -> ( Arc < TunnelMux > , mpsc:: Receiver < MuxMsg > ) {
2321- let ( tx, rx) = mpsc:: channel ( 16 ) ;
2289+ fn mux_for_test_with ( num_scripts : usize ) -> ( Arc < TunnelMux > , mpsc:: UnboundedReceiver < MuxMsg > ) {
2290+ let ( tx, rx) = mpsc:: unbounded_channel ( ) ;
23222291 let mux = Arc :: new ( TunnelMux {
23232292 tx,
23242293 connect_data_unsupported : Arc :: new ( AtomicBool :: new ( false ) ) ,
0 commit comments