fix(remoteingress-core): preserve stream close ordering and add flow-control stall timeouts
This commit is contained in:
@@ -703,13 +703,17 @@ async fn handle_client_connection(
|
||||
// Task: client -> hub (upload direction) with per-stream flow control
|
||||
let mut buf = vec![0u8; 32768];
|
||||
loop {
|
||||
// Wait for send window to have capacity
|
||||
// Wait for send window to have capacity (with stall timeout)
|
||||
loop {
|
||||
let w = send_window.load(Ordering::Acquire);
|
||||
if w > 0 { break; }
|
||||
tokio::select! {
|
||||
_ = window_notify.notified() => continue,
|
||||
_ = client_token.cancelled() => break,
|
||||
_ = tokio::time::sleep(Duration::from_secs(120)) => {
|
||||
log::warn!("Stream {} upload stalled (window empty for 120s)", stream_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if client_token.is_cancelled() { break; }
|
||||
@@ -737,10 +741,10 @@ async fn handle_client_connection(
|
||||
}
|
||||
}
|
||||
|
||||
// Send CLOSE frame via control channel (only if not cancelled)
|
||||
// Send CLOSE frame via DATA channel (must arrive AFTER last DATA for this stream)
|
||||
if !client_token.is_cancelled() {
|
||||
let close_frame = encode_frame(stream_id, FRAME_CLOSE, &[]);
|
||||
let _ = tunnel_ctrl_tx.try_send(close_frame);
|
||||
let _ = tunnel_data_tx.try_send(close_frame);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
|
||||
Reference in New Issue
Block a user