Skip to content

Commit

Permalink
Fewer unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed Aug 6, 2024
1 parent 9fa21ee commit 21e9782
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
22 changes: 13 additions & 9 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,15 +1547,19 @@ impl Connection {

qlog::packet_received(&self.qlog, &packet, &payload);
let space = PacketNumberSpace::from(payload.packet_type());
if self.acks.get_mut(space).unwrap().is_duplicate(payload.pn()) {
qdebug!([self], "Duplicate packet {}-{}", space, payload.pn());
self.stats.borrow_mut().dups_rx += 1;
} else {
match self.process_packet(path, &payload, now) {
Ok(migrate) => self.postprocess_packet(path, d, &packet, migrate, now),
Err(e) => {
self.ensure_error_path(path, &packet, now);
return Err(e);
if let Some(space) = self.acks.get_mut(space) {
if space.is_duplicate(payload.pn()) {
qdebug!("Duplicate packet {}-{}", space, payload.pn());
self.stats.borrow_mut().dups_rx += 1;
} else {
match self.process_packet(path, &payload, now) {
Ok(migrate) => {
self.postprocess_packet(path, d, &packet, migrate, now);
}
Err(e) => {
self.ensure_error_path(path, &packet, now);
return Err(e);
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions neqo-transport/src/tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,16 +588,16 @@ impl AckTracker {
ignore_order: bool,
) {
// Only ApplicationData ever delays ACK.
self.get_mut(PacketNumberSpace::ApplicationData)
.unwrap()
.ack_freq(seqno, tolerance, delay, ignore_order);
if let Some(space) = self.get_mut(PacketNumberSpace::ApplicationData) {
space.ack_freq(seqno, tolerance, delay, ignore_order);
}
}

// Force an ACK to be generated immediately (a PING was received).
pub fn immediate_ack(&mut self, now: Instant) {
self.get_mut(PacketNumberSpace::ApplicationData)
.unwrap()
.immediate_ack(now);
if let Some(space) = self.get_mut(PacketNumberSpace::ApplicationData) {
space.immediate_ack(now);
}
}

/// Determine the earliest time that an ACK might be needed.
Expand Down

0 comments on commit 21e9782

Please sign in to comment.