refactor(link): bound every teardown and handler wait behind one helper [CI]
This commit is contained in:
1 parent
c05842fd91
commit
d95acc6575
10 files changed
+130
-31
No files matched your search
@@ -27,9 +27,6 @@ public sealed class AgentConnection : IDisposable
|
||||
/// <summary>Agent 的任何帧(时钟回复、任务集)都算存活;比时钟同步间隔长得多,容得下差线路上的黑洞,但不会让一个 Agent 已经丢掉的会话永远挂着。</summary>
|
||||
private static readonly TimeSpan s_idleLimit = TimeSpan.FromSeconds(120);
|
||||
|
||||
/// <summary>收尾的每一步最多等这么久:QUIC 连接或控制连接的关闭卡在原生层时,不能让整个重拨循环跟着卡住。</summary>
|
||||
private static readonly TimeSpan s_teardownLimit = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary>一直在发测量报文、却这么久没有收到 Agent 的任何一个:数据面已经不通,重建会话。要比一次线路中断长(中断恢复后接着测),又不能拖到几个小时。</summary>
|
||||
private static readonly TimeSpan s_dataIdleLimit = TimeSpan.FromSeconds(90);
|
||||
private static readonly RpcRouter<ConnectionSession> s_router = BuildRouter();
|
||||
@@ -347,18 +344,10 @@ public sealed class AgentConnection : IDisposable
|
||||
|
||||
private async Task BoundedAsync(string step, Func<Task> work)
|
||||
{
|
||||
try
|
||||
{
|
||||
await work().WaitAsync(s_teardownLimit, _env.Time);
|
||||
}
|
||||
catch (TimeoutException)
|
||||
if (!await Bounded.WaitAsync(work(), Bounded.Teardown, _env.Time))
|
||||
{
|
||||
_env.Log.Warn("agent session teardown step timed out, moving on", ("agent", Endpoint.AgentId), ("step", step));
|
||||
}
|
||||
catch (Exception ex) when (ex is OperationCanceledException or IOException or ObjectDisposedException or System.Net.Sockets.SocketException or InvalidOperationException)
|
||||
{
|
||||
// 会话结束时的正常噪声
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task Quiet(Task task)
|
||||
|
||||
Reference in new issue
Block a user