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 <noreply@anthropic.com>
This commit is contained in:
parent
8e6c7d177e
commit
1e4f0c09d9
1 changed files with 16 additions and 14 deletions
|
|
@ -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<CultNetRudpReliableSendReceipt> {
|
||||
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<u64> {
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue