From 1e4f0c09d9e2874f79686e0a6b20e8f0f1fb5ac6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 10:39:34 +0100 Subject: [PATCH] cultnet-rs: a send queued behind a full window returns a pending receipt, not an error (P10) send_reliable built its receipt from the packets that went on the wire; a full flow window queues them, leaving the set empty. The receipt now covers every sequence the send assigned, and a queued sequence reads Pending. Co-Authored-By: Claude Sonnet 5.5 --- packages/cultnet-rs/src/rudp.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/cultnet-rs/src/rudp.rs b/packages/cultnet-rs/src/rudp.rs index 427a38c1..347312de 100644 --- a/packages/cultnet-rs/src/rudp.rs +++ b/packages/cultnet-rs/src/rudp.rs @@ -398,7 +398,13 @@ impl CultNetRudpSession { if receipt .sequences .iter() - .any(|sequence| self.pending_reliable.contains_key(sequence)) + .any(|sequence| { + self.pending_reliable.contains_key(sequence) + || self + .queued_reliable + .iter() + .any(|(packet, _)| packet.sequence == *sequence) + }) { CultNetRudpReliableSendStatus::Pending } else { @@ -406,20 +412,15 @@ impl CultNetRudpSession { } } - fn non_expiring_reliable_receipt( - &self, - packets: &[CultNetRudpPacket], - ) -> Result { - if packets.is_empty() || packets.iter().any(|packet| !packet.reliable) { - return Err(anyhow!( - "RUDP acknowledgement receipts require a non-empty reliable packet set" - )); - } - Ok(CultNetRudpReliableSendReceipt { + /// A receipt for the reliable packets a send just created, those still + /// queued behind a full window included: their sequences were assigned + /// when they were made, and they read `Pending` until acknowledged. + fn reliable_receipt_from(&self, first_sequence: u32) -> CultNetRudpReliableSendReceipt { + CultNetRudpReliableSendReceipt { session_id: self.session_id, generation: self.generation, - sequences: packets.iter().map(|packet| packet.sequence).collect(), - }) + sequences: (first_sequence..self.next_sequence).collect(), + } } pub fn last_received_at_ms(&self) -> Option { @@ -2252,11 +2253,12 @@ impl CultNetRudpSocketTransportConnection { "RUDP acknowledgement receipts require a non-expiring reliable channel" )); } + let first_sequence = self.session.next_sequence; let packets = self.session .send_many(channel_id, payload, options, self.max_fragment_bytes)?; + let receipt = self.session.reliable_receipt_from(first_sequence); self.send_data_packets(&packets)?; - let receipt = self.session.non_expiring_reliable_receipt(&packets)?; self.stats.frames_sent += 1; Ok(receipt) }