fix(quic): exclude locally rejected datagrams [CI]
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/dev-image Pipeline was canceled

This commit is contained in:
justme committed 2026-10-11 19:58:36 +08:00
1 parent f6e477fb10
commit e82b165eb0
7 files changed
+131 -17

No files matched your search

@@ -51,7 +51,7 @@ public sealed class AgentConnection : IDisposable
public KnownAgent Endpoint { get; }
public bool IsConnected => _session is not null;
public bool IsConnected => _session is not null && Volatile.Read(ref _activeDatagrams)?.IsConnected == true;
public int RoleCount => _session?.RoleCount ?? 0;
@@ -91,16 +91,26 @@ public sealed class AgentConnection : IDisposable
p95 = sorted[(int)Math.Ceiling(sorted.Length * 0.95) - 1];
}
QuicTransportSnapshot? transport = Volatile.Read(ref _activeDatagrams)?.GetTransportSnapshot();
QuicDatagramTransport? datagrams = Volatile.Read(ref _activeDatagrams);
bool connected = _session is not null && datagrams?.IsConnected == true;
ProbeLinkAttemptState state = _attemptState;
string? lastError = _lastError;
if (!connected && state == ProbeLinkAttemptState.Connected)
{
state = ProbeLinkAttemptState.RetryWait;
lastError ??= "QUIC datagram transport is closed; reconnecting";
}
QuicTransportSnapshot? transport = datagrams?.GetTransportSnapshot();
return new ProbeQuicLinkHealth
{
AgentId = Endpoint.AgentId,
IpVersion = Endpoint.IpVersion,
Connected = IsConnected,
State = _attemptState,
LastError = _lastError,
Connected = connected,
State = state,
LastError = lastError,
RetryAttempt = _lastRetryAttempt,
RetryInMs = _attemptState == ProbeLinkAttemptState.RetryWait && _retryAt is { } retryAt
RetryInMs = state == ProbeLinkAttemptState.RetryWait && _retryAt is { } retryAt
? Math.Max(0, (long)(retryAt - _env.Time.GetUtcNow()).TotalMilliseconds)
: null,
HandshakeAttempts = _handshakeAttempts,
@@ -282,9 +292,21 @@ public sealed class AgentConnection : IDisposable
_env.Log.Info("agent session up", ("agent", Endpoint.AgentId), ("offset_us", clock.OffsetUs));
Task maintenance = MaintainAsync(rpc, session, clock, cts.Token);
Task finished = await Task.WhenAny(run, receive, pump, maintenance);
string reason = finished == run
? "closed by the Agent control connection"
: finished == receive
? "QUIC datagram transport closed"
: finished == pump
? "Probe outbox pump stopped"
: "connection maintenance stopped";
if (finished.IsFaulted && finished.Exception?.GetBaseException() is { } error)
{
reason = $"{error.GetType().Name}: {error.Message}";
}
await cts.CancelAsync();
await Task.WhenAll(Quiet(run), Quiet(receive), Quiet(pump), Quiet(maintenance));
return finished == run ? "closed by the agent" : "session task failed";
return reason;
}
finally
{