remove streamFramer.HasData()

ref #217
This commit is contained in:
Lucas Clemente 2016-07-25 17:27:39 +02:00
parent 136a1c574c
commit d9a3980efc
3 changed files with 76 additions and 130 deletions

View file

@ -447,7 +447,6 @@ func (s *Session) closeStreamWithError(str *stream, err error) {
str.RegisterError(err)
}
// TODO: try sending more than one packet
func (s *Session) maybeSendPacket() error {
if !s.smallPacketDelayedOccurranceTime.IsZero() && time.Now().Sub(s.smallPacketDelayedOccurranceTime) > protocol.SmallPacketSendDelay {
return s.sendPacket()
@ -503,6 +502,8 @@ func (s *Session) maybeSendPacket() error {
func (s *Session) sendPacket() error {
s.smallPacketDelayedOccurranceTime = time.Time{} // zero
// Repeatedly try sending until we don't have any more data, or run out of the congestion window
for {
err := s.sentPacketHandler.CheckForError()
if err != nil {
return err
@ -548,7 +549,6 @@ func (s *Session) sendPacket() error {
stopWaitingFrame := s.stopWaitingManager.GetStopWaitingFrame()
packet, err := s.packer.PackPacket(stopWaitingFrame, controlFrames, s.sentPacketHandler.GetLargestAcked())
if err != nil {
return err
}
@ -579,11 +579,7 @@ func (s *Session) sendPacket() error {
return err
}
if s.streamFramer.HasData() {
s.scheduleSending()
}
return nil
}
func (s *Session) sendConnectionClose(quicErr *qerr.QuicError) error {

View file

@ -28,28 +28,6 @@ func newStreamFramer(streams *map[protocol.StreamID]*stream, streamsMutex *sync.
}
}
func (f *streamFramer) HasData() bool {
if len(f.retransmissionQueue) > 0 {
return true
}
f.streamsMutex.RLock()
defer f.streamsMutex.RUnlock()
for _, s := range *f.streams {
if s == nil {
continue
}
// An error should never happen, and needlessly complicates the return values
fcLimit, _ := f.getFCAllowanceForStream(s)
if fcLimit == 0 {
continue
}
if s.lenOfDataForWriting() > 0 || s.shouldSendFin() {
return true
}
}
return false
}
func (f *streamFramer) AddFrameForRetransmission(frame *frames.StreamFrame) {
f.retransmissionQueue = append(f.retransmissionQueue, frame)
}

View file

@ -59,34 +59,6 @@ var _ = Describe("Stream Framer", func() {
Expect(fs[0].DataLenPresent).To(BeTrue())
})
Context("HasData", func() {
It("has no data initially", func() {
Expect(framer.HasData()).To(BeFalse())
})
It("has data with retransmitted frames", func() {
framer.AddFrameForRetransmission(retransmittedFrame1)
Expect(framer.HasData()).To(BeTrue())
})
It("has data with normal frames", func() {
stream1.dataForWriting = []byte("foobar")
Expect(framer.HasData()).To(BeTrue())
})
It("has data with FIN frames", func() {
stream1.closed = 1
Expect(framer.HasData()).To(BeTrue())
})
It("has no data when FC blocked", func() {
stream1.dataForWriting = []byte("foobar")
Expect(framer.HasData()).To(BeTrue())
fcm.sendWindowSizes[stream1.StreamID()] = 0
Expect(framer.HasData()).To(BeFalse())
})
})
Context("Framer estimated data length", func() {
It("returns the correct length for an empty framer", func() {
Expect(framer.EstimatedDataLen()).To(BeZero())
@ -227,10 +199,10 @@ var _ = Describe("Stream Framer", func() {
framer.AddFrameForRetransmission(retransmittedFrame2)
fs := framer.PopStreamFrames(6)
Expect(fs).To(HaveLen(1))
Expect(framer.HasData()).To(BeTrue())
Expect(framer.retransmissionQueue).ToNot(BeEmpty())
fs = framer.PopStreamFrames(1000)
Expect(fs).To(HaveLen(1))
Expect(framer.HasData()).To(BeFalse())
Expect(framer.retransmissionQueue).To(BeEmpty())
})
It("gets the whole data of a frame if it was split", func() {