Skip to content

Commit a89424c

Browse files
committed
Factor alloc_new_identifiers call into queue_new_cids
1 parent 94adb21 commit a89424c

File tree

1 file changed

+7
-10
lines changed
  • quinn-proto/src/connection

1 file changed

+7
-10
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
range_set::ArrayRangeSet,
2727
shared::{
2828
ConnectionEvent, ConnectionEventInner, ConnectionId, EcnCodepoint, EndpointEvent,
29-
EndpointEventInner, IssuedCid,
29+
EndpointEventInner,
3030
},
3131
token::ResetToken,
3232
transport_parameters::TransportParameters,
@@ -938,7 +938,8 @@ impl Connection {
938938
}
939939
}
940940

941-
fn queue_new_cids(&mut self, now: Instant, ids: Vec<IssuedCid>) {
941+
fn queue_new_cids(&mut self, now: Instant, count: u64, endpoint: &Endpoint) {
942+
let ids = endpoint.alloc_new_identifiers(self.handle, count);
942943
self.local_cid_state.new_cids(&ids, now);
943944
ids.into_iter().rev().for_each(|frame| {
944945
self.spaces[SpaceId::Data].pending.new_cids.push(frame);
@@ -1005,8 +1006,7 @@ impl Connection {
10051006
"push a new cid to peer RETIRE_PRIOR_TO field {}",
10061007
self.local_cid_state.retire_prior_to()
10071008
);
1008-
let ids = endpoint.alloc_new_identifiers(self.handle, num_new_cid);
1009-
self.queue_new_cids(now, ids);
1009+
self.queue_new_cids(now, num_new_cid, endpoint);
10101010
}
10111011
}
10121012
}
@@ -2624,8 +2624,7 @@ impl Connection {
26242624
.on_cid_retirement(sequence, self.peer_params.issue_cids_limit())?;
26252625
endpoint.retire_cid(self.handle, sequence);
26262626
if allow_more_cids {
2627-
let ids = endpoint.alloc_new_identifiers(self.handle, 1);
2628-
self.queue_new_cids(now, ids);
2627+
self.queue_new_cids(now, 1, endpoint);
26292628
}
26302629
}
26312630
Frame::NewConnectionId(frame) => {
@@ -2824,8 +2823,7 @@ impl Connection {
28242823

28252824
// Subtract 1 to account for the CID we supplied while handshaking
28262825
let n = self.peer_params.issue_cids_limit() - 1;
2827-
let ids = endpoint.alloc_new_identifiers(self.handle, n);
2828-
self.queue_new_cids(now, ids);
2826+
self.queue_new_cids(now, n, endpoint);
28292827
}
28302828

28312829
fn populate_packet(
@@ -3238,8 +3236,7 @@ impl Connection {
32383236
#[cfg(test)]
32393237
pub(crate) fn rotate_local_cid(&mut self, v: u64, now: Instant, endpoint: &Endpoint) {
32403238
let n = self.local_cid_state.assign_retire_seq(v);
3241-
let ids = endpoint.alloc_new_identifiers(self.handle, n);
3242-
self.queue_new_cids(now, ids);
3239+
self.queue_new_cids(now, n, endpoint);
32433240
}
32443241

32453242
/// Check the current active remote CID sequence

0 commit comments

Comments
 (0)