Skip to content

Commit

Permalink
quinn-proto: inline single-use method
Browse files Browse the repository at this point in the history
  • Loading branch information
djc authored and Ralith committed Feb 22, 2021
1 parent 8630946 commit 095f402
Showing 1 changed file with 30 additions and 50 deletions.
80 changes: 30 additions & 50 deletions quinn-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,31 +870,40 @@ where
let ack_eliciting = builder.ack_eliciting;
let exact_number = builder.exact_number;
let space_id = builder.space;
let (size, padded) = self.finish_packet(builder, buffer);

let mut sent = match sent {
let (size, _) = self.finish_packet(builder, buffer);
let sent = match sent {
Some(sent) => sent,
None => return,
};

sent.padding = padded;
self.on_packet_sent(
now,
space_id,
exact_number,
SentPacket {
acks: sent.acks,
time_sent: now,
size: if sent.padding || ack_eliciting {
size as u16
} else {
0
},
ack_eliciting,
retransmits: sent.retransmits,
stream_frames: sent.stream_frames,
},
);
let size = match sent.padding || ack_eliciting {
true => size as u16,
false => 0,
};

let packet = SentPacket {
acks: sent.acks,
time_sent: now,
size,
ack_eliciting,
retransmits: sent.retransmits,
stream_frames: sent.stream_frames,
};

self.in_flight.insert(&packet);
self.spaces[space_id].sent(exact_number, packet);
self.reset_keep_alive(now);
if size != 0 {
if ack_eliciting {
self.spaces[space_id].time_of_last_ack_eliciting_packet = Some(now);
if self.permit_idle_reset {
self.reset_idle_timeout(now);
}
self.permit_idle_reset = false;
}
self.set_loss_detection_timer(now);
self.path.pacing.on_transmit(size);
}
}

/// Process `ConnectionEvent`s generated by the associated `Endpoint`
Expand Down Expand Up @@ -1326,35 +1335,6 @@ where
self.path.rtt.get()
}

fn on_packet_sent(
&mut self,
now: Instant,
space: SpaceId,
packet_number: u64,
packet: SentPacket,
) {
let SentPacket {
size,
ack_eliciting,
..
} = packet;

self.in_flight.insert(&packet);
self.spaces[space].sent(packet_number, packet);
self.reset_keep_alive(now);
if size != 0 {
if ack_eliciting {
self.spaces[space].time_of_last_ack_eliciting_packet = Some(now);
if self.permit_idle_reset {
self.reset_idle_timeout(now);
}
self.permit_idle_reset = false;
}
self.set_loss_detection_timer(now);
self.path.pacing.on_transmit(size);
}
}

fn on_ack_received(
&mut self,
now: Instant,
Expand Down

0 comments on commit 095f402

Please sign in to comment.