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
|
if receipt
|
||||||
.sequences
|
.sequences
|
||||||
.iter()
|
.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
|
CultNetRudpReliableSendStatus::Pending
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -406,20 +412,15 @@ impl CultNetRudpSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn non_expiring_reliable_receipt(
|
/// A receipt for the reliable packets a send just created, those still
|
||||||
&self,
|
/// queued behind a full window included: their sequences were assigned
|
||||||
packets: &[CultNetRudpPacket],
|
/// when they were made, and they read `Pending` until acknowledged.
|
||||||
) -> Result<CultNetRudpReliableSendReceipt> {
|
fn reliable_receipt_from(&self, first_sequence: u32) -> CultNetRudpReliableSendReceipt {
|
||||||
if packets.is_empty() || packets.iter().any(|packet| !packet.reliable) {
|
CultNetRudpReliableSendReceipt {
|
||||||
return Err(anyhow!(
|
|
||||||
"RUDP acknowledgement receipts require a non-empty reliable packet set"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Ok(CultNetRudpReliableSendReceipt {
|
|
||||||
session_id: self.session_id,
|
session_id: self.session_id,
|
||||||
generation: self.generation,
|
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> {
|
pub fn last_received_at_ms(&self) -> Option<u64> {
|
||||||
|
|
@ -2252,11 +2253,12 @@ impl CultNetRudpSocketTransportConnection {
|
||||||
"RUDP acknowledgement receipts require a non-expiring reliable channel"
|
"RUDP acknowledgement receipts require a non-expiring reliable channel"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
let first_sequence = self.session.next_sequence;
|
||||||
let packets =
|
let packets =
|
||||||
self.session
|
self.session
|
||||||
.send_many(channel_id, payload, options, self.max_fragment_bytes)?;
|
.send_many(channel_id, payload, options, self.max_fragment_bytes)?;
|
||||||
|
let receipt = self.session.reliable_receipt_from(first_sequence);
|
||||||
self.send_data_packets(&packets)?;
|
self.send_data_packets(&packets)?;
|
||||||
let receipt = self.session.non_expiring_reliable_receipt(&packets)?;
|
|
||||||
self.stats.frames_sent += 1;
|
self.stats.frames_sent += 1;
|
||||||
Ok(receipt)
|
Ok(receipt)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue