diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index addd9f24c..d3cfaeb21 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -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` @@ -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,