mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
queue stream-level window updates from the flow controller directly
This commit is contained in:
parent
b93827ca60
commit
2e8a5807ba
9 changed files with 73 additions and 77 deletions
|
@ -43,7 +43,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("reads a single STREAM frame", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(4))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
frame := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
|
@ -61,7 +61,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2))
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2))
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
|
@ -83,7 +83,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), false)
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2)).Times(2)
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD},
|
||||
|
@ -107,7 +107,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), false)
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2)).Times(2)
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD},
|
||||
|
@ -130,7 +130,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("waits until data is available", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
frame := wire.StreamFrame{Data: []byte{0xDE, 0xAD}}
|
||||
|
@ -148,7 +148,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), false)
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2)).Times(2)
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 2,
|
||||
Data: []byte{0xBE, 0xEF},
|
||||
|
@ -173,7 +173,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), false)
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2)).Times(2)
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD},
|
||||
|
@ -204,7 +204,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2))
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(4))
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte("foob"),
|
||||
|
@ -230,22 +230,6 @@ var _ = Describe("Receive Stream", func() {
|
|||
Expect(err).To(MatchError(errEmptyStreamData))
|
||||
})
|
||||
|
||||
It("calls the onHasWindowUpdate callback, when the a MAX_STREAM_DATA should be sent", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), false)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(6))
|
||||
mockFC.EXPECT().HasWindowUpdate().Return(true)
|
||||
mockSender.EXPECT().onHasWindowUpdate(streamID)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte("foobar"),
|
||||
}
|
||||
err := str.handleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 6)
|
||||
_, err = strWithTimeout.Read(b)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
Context("deadlines", func() {
|
||||
It("the deadline error has the right net.Error properties", func() {
|
||||
Expect(errDeadline.Temporary()).To(BeTrue())
|
||||
|
@ -318,7 +302,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("returns EOFs", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), true)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(4))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
str.handleStreamFrame(&wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
|
@ -339,7 +323,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), false)
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(4), true)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2)).Times(2)
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
frame1 := wire.StreamFrame{
|
||||
Offset: 2,
|
||||
Data: []byte{0xBE, 0xEF},
|
||||
|
@ -367,7 +351,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("returns EOFs with partial read", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(2), true)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
err := str.handleStreamFrame(&wire.StreamFrame{
|
||||
Offset: 0,
|
||||
Data: []byte{0xde, 0xad},
|
||||
|
@ -385,7 +369,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("handles immediate FINs", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(0), true)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(0))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
err := str.handleStreamFrame(&wire.StreamFrame{
|
||||
Offset: 0,
|
||||
FinBit: true,
|
||||
|
@ -402,7 +386,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("closes when CloseRemote is called", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(0), true)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(0))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
str.CloseRemote(0)
|
||||
mockSender.EXPECT().onStreamCompleted(streamID)
|
||||
b := make([]byte, 8)
|
||||
|
@ -478,7 +462,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
It("doesn't send a RST_STREAM frame, if the FIN was already read", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), true)
|
||||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(6))
|
||||
mockFC.EXPECT().HasWindowUpdate()
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate()
|
||||
// no calls to mockSender.queueControlFrame
|
||||
err := str.handleStreamFrame(&wire.StreamFrame{
|
||||
StreamID: streamID,
|
||||
|
@ -601,7 +585,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(2)),
|
||||
mockSender.EXPECT().onStreamCompleted(streamID),
|
||||
)
|
||||
mockFC.EXPECT().HasWindowUpdate().Times(2)
|
||||
mockFC.EXPECT().MaybeQueueWindowUpdate().Times(2)
|
||||
readReturned := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue