fix: prevent QUIC heartbeat stalls and isolate TCP retransmission counters [CI] [SKIP TESTS]
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/dev-image Pipeline was successful

This commit is contained in:
justme committed 2026-10-20 18:23:31 +08:00
1 parent 0066a947da
commit 0fd38b2367
14 files changed
+299 -50

No files matched your search

@@ -1,3 +1,4 @@
using System.Buffers;
using System.Buffers.Binary;
using System.Security.Cryptography;
using Fleet.Core;
@@ -124,9 +125,18 @@ public static class TcpWire
public static async ValueTask WriteMessageAsync(Stream stream, ReadOnlyMemory<byte> body, CancellationToken ct)
{
byte[] prefix = new byte[VarInt.MaxBytes];
int n = VarInt.Write(prefix, (ulong)body.Length);
await stream.WriteAsync(prefix.AsMemory(0, n), ct);
await stream.WriteAsync(body, ct);
byte[] frame = ArrayPool<byte>.Shared.Rent(checked(VarInt.MaxBytes + body.Length));
try
{
int n = VarInt.Write(frame, (ulong)body.Length);
body.CopyTo(frame.AsMemory(n));
// TCP_NODELAY is enabled: two writes otherwise create a tiny
// length-only segment before every echo body (and two TLS records).
await stream.WriteAsync(frame.AsMemory(0, n + body.Length), ct);
}
finally
{
ArrayPool<byte>.Shared.Return(frame);
}
}
}