better function name in SentPacketHandler

This commit is contained in:
Marten Seemann
2016-05-24 15:39:48 +07:00
parent 9539169fa4
commit 931687e9a4
5 changed files with 8 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ type SentPacketHandler interface {
BytesInFlight() protocol.ByteCount
GetLargestObserved() protocol.PacketNumber
AllowsSending() bool
CongestionAllowsSending() bool
TimeToFirstRTO() time.Duration
}

View File

@@ -274,7 +274,7 @@ func (h *sentPacketHandler) GetLargestObserved() protocol.PacketNumber {
return h.LargestObserved
}
func (h *sentPacketHandler) AllowsSending() bool {
func (h *sentPacketHandler) CongestionAllowsSending() bool {
return h.BytesInFlight() <= h.congestion.GetCongestionWindow()
}

View File

@@ -589,10 +589,10 @@ var _ = Describe("SentPacketHandler", func() {
})
It("allows or denies sending", func() {
Expect(handler.AllowsSending()).To(BeTrue())
Expect(handler.CongestionAllowsSending()).To(BeTrue())
err := handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: protocol.DefaultTCPMSS + 1})
Expect(err).NotTo(HaveOccurred())
Expect(handler.AllowsSending()).To(BeFalse())
Expect(handler.CongestionAllowsSending()).To(BeFalse())
})
It("should call OnRetransmissionTimeout", func() {

View File

@@ -21,7 +21,7 @@ func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandler.Pac
func (h *mockSentPacketHandler) HasPacketForRetransmission() bool { return false }
func (h *mockSentPacketHandler) BytesInFlight() protocol.ByteCount { return 0 }
func (h *mockSentPacketHandler) GetLargestObserved() protocol.PacketNumber { return 1 }
func (h *mockSentPacketHandler) AllowsSending() bool { panic("not implemented") }
func (h *mockSentPacketHandler) CongestionAllowsSending() bool { panic("not implemented") }
func (h *mockSentPacketHandler) TimeToFirstRTO() time.Duration { panic("not implemented") }
func newMockSentPacketHandler() ackhandler.SentPacketHandler {

View File

@@ -144,7 +144,7 @@ func (s *Session) run() {
firstTimeout := utils.InfDuration
// Some timeouts are only set when we can actually send
// Note: if a packet arrives, we go through this again afterwards.
if s.sentPacketHandler.AllowsSending() {
if s.sentPacketHandler.CongestionAllowsSending() {
// Small packet send delay
if !s.smallPacketDelayedOccurranceTime.IsZero() {
firstTimeout = utils.MinDuration(firstTimeout, s.smallPacketDelayedOccurranceTime.Add(protocol.SmallPacketSendDelay).Sub(now))
@@ -414,7 +414,7 @@ func (s *Session) maybeSendPacket() error {
return s.sendPacket()
}
if !s.sentPacketHandler.AllowsSending() {
if !s.sentPacketHandler.CongestionAllowsSending() {
return nil
}
@@ -463,7 +463,7 @@ func (s *Session) maybeSendPacket() error {
func (s *Session) sendPacket() error {
s.smallPacketDelayedOccurranceTime = time.Time{} // zero
if !s.sentPacketHandler.AllowsSending() {
if !s.sentPacketHandler.CongestionAllowsSending() {
return nil
}