diff --git a/h2quic/response_writer_test.go b/h2quic/response_writer_test.go index bb005be5..02d8cca7 100644 --- a/h2quic/response_writer_test.go +++ b/h2quic/response_writer_test.go @@ -44,7 +44,7 @@ func newMockStream(id protocol.StreamID) *mockStream { } func (s *mockStream) Close() error { s.closed = true; s.ctxCancel(); return nil } -func (s *mockStream) CancelRead(quic.ErrorCode) error { s.canceledRead = true; return nil } +func (s *mockStream) CancelRead(quic.ErrorCode) { s.canceledRead = true } func (s *mockStream) CancelWrite(quic.ErrorCode) error { s.canceledWrite = true; return nil } func (s *mockStream) CloseRemote(offset protocol.ByteCount) { s.remoteClosed = true; s.ctxCancel() } func (s mockStream) StreamID() protocol.StreamID { return s.id } diff --git a/integrationtests/self/cancelation_test.go b/integrationtests/self/cancelation_test.go index 8274d33c..269385d4 100644 --- a/integrationtests/self/cancelation_test.go +++ b/integrationtests/self/cancelation_test.go @@ -82,7 +82,7 @@ var _ = Describe("Stream Cancelations", func() { // cancel around 2/3 of the streams if rand.Int31()%3 != 0 { atomic.AddInt32(&canceledCounter, 1) - Expect(str.CancelRead(quic.ErrorCode(str.StreamID()))).To(Succeed()) + str.CancelRead(quic.ErrorCode(str.StreamID())) return } data, err := ioutil.ReadAll(str) @@ -128,7 +128,7 @@ var _ = Describe("Stream Cancelations", func() { length := int(rand.Int31n(int32(len(testserver.PRData) - 1))) data, err := ioutil.ReadAll(io.LimitReader(str, int64(length))) Expect(err).ToNot(HaveOccurred()) - Expect(str.CancelRead(quic.ErrorCode(str.StreamID()))).To(Succeed()) + str.CancelRead(quic.ErrorCode(str.StreamID())) Expect(data).To(Equal(testserver.PRData[:length])) atomic.AddInt32(&canceledCounter, 1) return @@ -309,7 +309,7 @@ var _ = Describe("Stream Cancelations", func() { Expect(err).ToNot(HaveOccurred()) // cancel around half of the streams if rand.Int31()%2 == 0 { - Expect(str.CancelRead(quic.ErrorCode(str.StreamID()))).To(Succeed()) + str.CancelRead(quic.ErrorCode(str.StreamID())) return } data, err := ioutil.ReadAll(str) @@ -401,7 +401,7 @@ var _ = Describe("Stream Cancelations", func() { } Expect(data).To(Equal(testserver.PRData[:length])) if length < len(testserver.PRData) { - Expect(str.CancelRead(quic.ErrorCode(str.StreamID()))).To(Succeed()) + str.CancelRead(quic.ErrorCode(str.StreamID())) return } diff --git a/interface.go b/interface.go index bbefcf27..a05854c8 100644 --- a/interface.go +++ b/interface.go @@ -58,7 +58,7 @@ type Stream interface { // It will ask the peer to stop transmitting stream data. // Read will unblock immediately, and future Read calls will fail. // When called multiple times or after reading the io.EOF it is a no-op. - CancelRead(ErrorCode) error + CancelRead(ErrorCode) // The context is canceled as soon as the write-side of the stream is closed. // This happens when Close() is called, or when the stream is reset (either locally or remotely). // Warning: This API should not be considered stable and might change soon. @@ -86,7 +86,7 @@ type ReceiveStream interface { // see Stream.Read io.Reader // see Stream.CancelRead - CancelRead(ErrorCode) error + CancelRead(ErrorCode) // see Stream.SetReadDealine SetReadDeadline(t time.Time) error } diff --git a/mock_receive_stream_internal_test.go b/mock_receive_stream_internal_test.go index cfe02b55..4060d279 100644 --- a/mock_receive_stream_internal_test.go +++ b/mock_receive_stream_internal_test.go @@ -37,10 +37,8 @@ func (m *MockReceiveStreamI) EXPECT() *MockReceiveStreamIMockRecorder { } // CancelRead mocks base method -func (m *MockReceiveStreamI) CancelRead(arg0 protocol.ApplicationErrorCode) error { - ret := m.ctrl.Call(m, "CancelRead", arg0) - ret0, _ := ret[0].(error) - return ret0 +func (m *MockReceiveStreamI) CancelRead(arg0 protocol.ApplicationErrorCode) { + m.ctrl.Call(m, "CancelRead", arg0) } // CancelRead indicates an expected call of CancelRead diff --git a/mock_stream_internal_test.go b/mock_stream_internal_test.go index c3c69fd5..b07d69f8 100644 --- a/mock_stream_internal_test.go +++ b/mock_stream_internal_test.go @@ -38,10 +38,8 @@ func (m *MockStreamI) EXPECT() *MockStreamIMockRecorder { } // CancelRead mocks base method -func (m *MockStreamI) CancelRead(arg0 protocol.ApplicationErrorCode) error { - ret := m.ctrl.Call(m, "CancelRead", arg0) - ret0, _ := ret[0].(error) - return ret0 +func (m *MockStreamI) CancelRead(arg0 protocol.ApplicationErrorCode) { + m.ctrl.Call(m, "CancelRead", arg0) } // CancelRead indicates an expected call of CancelRead diff --git a/receive_stream.go b/receive_stream.go index a14c2512..59deb744 100644 --- a/receive_stream.go +++ b/receive_stream.go @@ -190,12 +190,12 @@ func (s *receiveStream) dequeueNextFrame() { s.readPosInFrame = 0 } -func (s *receiveStream) CancelRead(errorCode protocol.ApplicationErrorCode) error { +func (s *receiveStream) CancelRead(errorCode protocol.ApplicationErrorCode) { s.mutex.Lock() defer s.mutex.Unlock() if s.finRead || s.canceledRead || s.resetRemotely { - return nil + return } if s.finalOffset != protocol.MaxByteCount { // final offset was already received s.streamCompleted() @@ -207,7 +207,6 @@ func (s *receiveStream) CancelRead(errorCode protocol.ApplicationErrorCode) erro StreamID: s.streamID, ErrorCode: errorCode, }) - return nil } func (s *receiveStream) handleStreamFrame(frame *wire.StreamFrame) error { diff --git a/receive_stream_test.go b/receive_stream_test.go index dfb1c0c6..3e4e347f 100644 --- a/receive_stream_test.go +++ b/receive_stream_test.go @@ -458,21 +458,21 @@ var _ = Describe("Receive Stream", func() { close(done) }() Consistently(done).ShouldNot(BeClosed()) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) Eventually(done).Should(BeClosed()) }) It("doesn't allow further calls to Read", func() { mockSender.EXPECT().queueControlFrame(gomock.Any()) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) _, err := strWithTimeout.Read([]byte{0}) Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234")) }) It("does nothing when CancelRead is called twice", func() { mockSender.EXPECT().queueControlFrame(gomock.Any()) - Expect(str.CancelRead(1234)).To(Succeed()) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) + str.CancelRead(1234) _, err := strWithTimeout.Read([]byte{0}) Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234")) }) @@ -482,7 +482,7 @@ var _ = Describe("Receive Stream", func() { StreamID: streamID, ErrorCode: 1234, }) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) }) It("doesn't send a STOP_SENDING frame, if the FIN was already read", func() { @@ -497,7 +497,7 @@ var _ = Describe("Receive Stream", func() { mockSender.EXPECT().onStreamCompleted(streamID) _, err := strWithTimeout.Read(make([]byte, 100)) Expect(err).To(MatchError(io.EOF)) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) }) It("doesn't send a STOP_SENDING frame, if the stream was already reset", func() { @@ -510,7 +510,7 @@ var _ = Describe("Receive Stream", func() { StreamID: streamID, ByteOffset: 42, })).To(Succeed()) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) }) It("sends a STOP_SENDING and completes the stream after receiving the final offset", func() { @@ -522,12 +522,12 @@ var _ = Describe("Receive Stream", func() { mockFC.EXPECT().Abandon() mockSender.EXPECT().queueControlFrame(gomock.Any()) mockSender.EXPECT().onStreamCompleted(streamID) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) }) It("completes the stream when receiving the FinBit after the stream was canceled", func() { mockSender.EXPECT().queueControlFrame(gomock.Any()) - Expect(str.CancelRead(1234)).To(Succeed()) + str.CancelRead(1234) gomock.InOrder( mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(1000), true), mockFC.EXPECT().Abandon(),