mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
fix(tunnel): 为 hub reader body 推送添加超时, 防止流间 head-of-line blocking
push_body_chunk 原先使用无超时的 channel send, 当消费端慢时会阻塞 整条 proxy 连接的 reader, 导致同连接上其他 stream 的帧无法路由。 添加 5 秒超时后, 单个 stream 的背压不再影响其他 stream。
This commit is contained in:
@@ -282,10 +282,17 @@ impl LocalStream {
|
||||
if self.terminal.load(Ordering::Acquire) {
|
||||
return false;
|
||||
}
|
||||
self.body_tx
|
||||
.send(LocalBodyEvent::Chunk(payload))
|
||||
.await
|
||||
.is_ok()
|
||||
// Use a timeout to prevent a slow consumer from blocking the shared
|
||||
// proxy-connection reader (head-of-line blocking across streams).
|
||||
match tokio::time::timeout(
|
||||
Duration::from_secs(5),
|
||||
self.body_tx.send(LocalBodyEvent::Chunk(payload)),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(Ok(())) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn finish(&self) {
|
||||
|
||||
Reference in New Issue
Block a user