Skip to content

Commit

Permalink
rename lastSentAckElicitingPacketTime to lastAckElicitingPacketTime
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jun 1, 2020
1 parent c8e5bb5 commit feb3e9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions internal/ackhandler/sent_packet_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type packetNumberSpace struct {
history *sentPacketHistory
pns *packetNumberGenerator

lossTime time.Time
lastSentAckElicitingPacketTime time.Time
lossTime time.Time
lastAckElicitingPacketTime time.Time

largestAcked protocol.PacketNumber
largestSent protocol.PacketNumber
Expand Down Expand Up @@ -244,7 +244,7 @@ func (h *sentPacketHandler) sentPacketImpl(packet *Packet) bool /* is ack-elicit
isAckEliciting := len(packet.Frames) > 0

if isAckEliciting {
pnSpace.lastSentAckElicitingPacketTime = packet.SendTime
pnSpace.lastAckElicitingPacketTime = packet.SendTime
packet.includedInBytesInFlight = true
h.bytesInFlight += packet.Length
if h.numProbesToSend > 0 {
Expand Down Expand Up @@ -419,22 +419,22 @@ func (h *sentPacketHandler) getEarliestLossTimeAndSpace() (time.Time, protocol.E
return lossTime, encLevel
}

// same logic as getEarliestLossTimeAndSpace, but for lastSentAckElicitingPacketTime instead of lossTime
// same logic as getEarliestLossTimeAndSpace, but for lastAckElicitingPacketTime instead of lossTime
func (h *sentPacketHandler) getEarliestSentTimeAndSpace() (time.Time, protocol.EncryptionLevel) {
var encLevel protocol.EncryptionLevel
var sentTime time.Time

if h.initialPackets != nil {
sentTime = h.initialPackets.lastSentAckElicitingPacketTime
sentTime = h.initialPackets.lastAckElicitingPacketTime
encLevel = protocol.EncryptionInitial
}
if h.handshakePackets != nil && (sentTime.IsZero() || (!h.handshakePackets.lastSentAckElicitingPacketTime.IsZero() && h.handshakePackets.lastSentAckElicitingPacketTime.Before(sentTime))) {
sentTime = h.handshakePackets.lastSentAckElicitingPacketTime
if h.handshakePackets != nil && (sentTime.IsZero() || (!h.handshakePackets.lastAckElicitingPacketTime.IsZero() && h.handshakePackets.lastAckElicitingPacketTime.Before(sentTime))) {
sentTime = h.handshakePackets.lastAckElicitingPacketTime
encLevel = protocol.EncryptionHandshake
}
if h.handshakeComplete &&
(sentTime.IsZero() || (!h.appDataPackets.lastSentAckElicitingPacketTime.IsZero() && h.appDataPackets.lastSentAckElicitingPacketTime.Before(sentTime))) {
sentTime = h.appDataPackets.lastSentAckElicitingPacketTime
(sentTime.IsZero() || (!h.appDataPackets.lastAckElicitingPacketTime.IsZero() && h.appDataPackets.lastAckElicitingPacketTime.Before(sentTime))) {
sentTime = h.appDataPackets.lastAckElicitingPacketTime
encLevel = protocol.Encryption1RTT
}
return sentTime, encLevel
Expand Down
6 changes: 3 additions & 3 deletions internal/ackhandler/sent_packet_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,20 @@ var _ = Describe("SentPacketHandler", func() {
It("stores the sent time", func() {
sendTime := time.Now().Add(-time.Minute)
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 1, SendTime: sendTime}))
Expect(handler.appDataPackets.lastSentAckElicitingPacketTime).To(Equal(sendTime))
Expect(handler.appDataPackets.lastAckElicitingPacketTime).To(Equal(sendTime))
})

It("stores the sent time of Initial packets", func() {
sendTime := time.Now().Add(-time.Minute)
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 1, SendTime: sendTime, EncryptionLevel: protocol.EncryptionInitial}))
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2, SendTime: sendTime.Add(time.Hour), EncryptionLevel: protocol.Encryption1RTT}))
Expect(handler.initialPackets.lastSentAckElicitingPacketTime).To(Equal(sendTime))
Expect(handler.initialPackets.lastAckElicitingPacketTime).To(Equal(sendTime))
})

It("does not store non-ack-eliciting packets", func() {
handler.SentPacket(nonAckElicitingPacket(&Packet{PacketNumber: 1}))
Expect(handler.appDataPackets.history.Len()).To(BeZero())
Expect(handler.appDataPackets.lastSentAckElicitingPacketTime).To(BeZero())
Expect(handler.appDataPackets.lastAckElicitingPacketTime).To(BeZero())
Expect(handler.bytesInFlight).To(BeZero())
})
})
Expand Down

0 comments on commit feb3e9a

Please sign in to comment.