fix(proto): ensure ImmediateAcks are sent in Data space (#226)

* fix(proto): ensure ImmediateAcks are sent in Data space

Closes https://github.com/n0-computer/quinn/issues/225

* fix: ensure spaceid writing

* add another debug assertion

* fixup
This commit is contained in:
Friedel Ziegelmayer
2025-12-09 16:36:01 +01:00
committed by GitHub
parent 704a3f613e
commit 67df91c667
+13 -3
View File
@@ -1488,6 +1488,8 @@ impl Connection {
// Send MTU probe if necessary
if transmit.is_empty() && self.state.is_established() {
// MTU probing happens only in Data space.
let space_id = SpaceId::Data;
path_id = *self.paths.first_key_value().expect("one path must exist").0;
let probe_data = loop {
// We MTU probe all paths for which all of the following is true:
@@ -1501,9 +1503,7 @@ impl Connection {
&& !self.abandoned_paths.contains(&path_id);
let probe_size = eligible
.then(|| {
let next_pn = self.spaces[SpaceId::Data]
.for_path(path_id)
.peek_tx_number();
let next_pn = self.spaces[space_id].for_path(path_id).peek_tx_number();
self.path_data_mut(path_id).mtud.poll_transmit(now, next_pn)
})
.flatten();
@@ -5089,6 +5089,11 @@ impl Connection {
// IMMEDIATE_ACK
if mem::replace(&mut space.for_path(path_id).immediate_ack_pending, false) {
debug_assert_eq!(
space_id,
SpaceId::Data,
"immediate acks must be sent in the data space"
);
trace!("IMMEDIATE_ACK");
buf.write(frame::FrameType::IMMEDIATE_ACK);
sent.non_retransmits = true;
@@ -5882,6 +5887,11 @@ impl Connection {
/// According to the spec, this will result in an error if the remote endpoint does not support
/// the Acknowledgement Frequency extension
pub(crate) fn immediate_ack(&mut self, path_id: PathId) {
debug_assert_eq!(
self.highest_space,
SpaceId::Data,
"immediate ack must be written in the data space"
);
self.spaces[self.highest_space]
.for_path(path_id)
.immediate_ack_pending = true;