mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
don't send a STOP_SENDING if the stream was already reset by the peer
This commit is contained in:
parent
bfbf0bca48
commit
9888db457f
2 changed files with 27 additions and 23 deletions
|
@ -190,10 +190,7 @@ func (s *receiveStream) CancelRead(errorCode protocol.ApplicationErrorCode) erro
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.Unlock()
|
||||||
|
|
||||||
if s.finRead {
|
if s.finRead || s.canceledRead || s.resetRemotely {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if s.canceledRead {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
s.canceledRead = true
|
s.canceledRead = true
|
||||||
|
|
|
@ -481,30 +481,37 @@ var _ = Describe("Receive Stream", func() {
|
||||||
Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234"))
|
Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("doesn't send a RESET_STREAM frame, if the FIN was already read", func() {
|
|
||||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), true)
|
|
||||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(6))
|
|
||||||
// no calls to mockSender.queueControlFrame
|
|
||||||
err := str.handleStreamFrame(&wire.StreamFrame{
|
|
||||||
StreamID: streamID,
|
|
||||||
Data: []byte("foobar"),
|
|
||||||
FinBit: true,
|
|
||||||
})
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
mockSender.EXPECT().onStreamCompleted(streamID)
|
|
||||||
_, err = strWithTimeout.Read(make([]byte, 100))
|
|
||||||
Expect(err).To(MatchError(io.EOF))
|
|
||||||
err = str.CancelRead(1234)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
})
|
|
||||||
|
|
||||||
It("queues a STOP_SENDING frame", func() {
|
It("queues a STOP_SENDING frame", func() {
|
||||||
mockSender.EXPECT().queueControlFrame(&wire.StopSendingFrame{
|
mockSender.EXPECT().queueControlFrame(&wire.StopSendingFrame{
|
||||||
StreamID: streamID,
|
StreamID: streamID,
|
||||||
ErrorCode: 1234,
|
ErrorCode: 1234,
|
||||||
})
|
})
|
||||||
err := str.CancelRead(1234)
|
Expect(str.CancelRead(1234)).To(Succeed())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
})
|
||||||
|
|
||||||
|
It("doesn't send a STOP_SENDING frame, if the FIN was already read", func() {
|
||||||
|
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), true)
|
||||||
|
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(6))
|
||||||
|
// no calls to mockSender.queueControlFrame
|
||||||
|
Expect(str.handleStreamFrame(&wire.StreamFrame{
|
||||||
|
StreamID: streamID,
|
||||||
|
Data: []byte("foobar"),
|
||||||
|
FinBit: true,
|
||||||
|
})).To(Succeed())
|
||||||
|
mockSender.EXPECT().onStreamCompleted(streamID)
|
||||||
|
_, err := strWithTimeout.Read(make([]byte, 100))
|
||||||
|
Expect(err).To(MatchError(io.EOF))
|
||||||
|
Expect(str.CancelRead(1234)).To(Succeed())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("doesn't send a STOP_SENDING frame, if the stream was already reset", func() {
|
||||||
|
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true)
|
||||||
|
mockSender.EXPECT().onStreamCompleted(streamID)
|
||||||
|
Expect(str.handleResetStreamFrame(&wire.ResetStreamFrame{
|
||||||
|
StreamID: streamID,
|
||||||
|
ByteOffset: 42,
|
||||||
|
})).To(Succeed())
|
||||||
|
Expect(str.CancelRead(1234)).To(Succeed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue