Ack Cut 1c: a new generation drops what the old one owed before the queue is asked for room

A bounded session whose queue still held an unacknowledged Accept for a peer
that vanished refused the next Connect; the old server-mode path reset before
accepting, so this would have been a regression. accept_connect and
create_connect now end the generation first in every runtime, and a test per
runtime holds a one-slot queue to it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 06:50:23 +02:00
commit 0abb8d4380
8 changed files with 100 additions and 12 deletions

View file

@ -1026,11 +1026,12 @@ namespace GameCult.Networking
/// </summary>
public CultNetRudpPacket CreateConnect(long nowMs = 0, byte[]? payload = null)
{
EnsureReliableCapacity(1);
// A session that has had a peer starts a new generation: nothing it learned from that
// peer describes the one this Connect reaches.
// peer describes the one this Connect reaches, and what it still owed that peer no
// longer takes room in the queue.
if (_connectSequence.HasValue)
ResetPeerState();
EnsureReliableCapacity(1);
_ended = false;
var packet = CreatePacket(CultNetRudpPacketType.Connect, "control", payload ?? Array.Empty<byte>(), reliable: true, ordered: true, sequenced: false);
_connectSequence = packet.Sequence;
@ -1069,8 +1070,8 @@ namespace GameCult.Networking
if (ConnectRepeats(packet))
return AnswerRepeatedConnect(packet, nowMs);
EnsureReliableCapacity(1);
ResetPeerState();
EnsureReliableCapacity(1);
SeedReceived(packet.Sequence);
_connectSequence = packet.Sequence;
_connected = true;