remove the error return value from Stream.CancelWrite

This commit is contained in:
Marten Seemann 2019-01-24 09:37:28 +07:00
parent ca939df44e
commit 3372fa794c
7 changed files with 24 additions and 32 deletions

View file

@ -241,21 +241,20 @@ func (s *sendStream) Close() error {
return nil
}
func (s *sendStream) CancelWrite(errorCode protocol.ApplicationErrorCode) error {
func (s *sendStream) CancelWrite(errorCode protocol.ApplicationErrorCode) {
s.mutex.Lock()
completed, err := s.cancelWriteImpl(errorCode, fmt.Errorf("Write on stream %d canceled with error code %d", s.streamID, errorCode))
completed := s.cancelWriteImpl(errorCode, fmt.Errorf("Write on stream %d canceled with error code %d", s.streamID, errorCode))
s.mutex.Unlock()
if completed {
s.sender.onStreamCompleted(s.streamID) // must be called without holding the mutex
}
return err
}
// must be called after locking the mutex
func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, writeErr error) (bool /*completed */, error) {
func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, writeErr error) bool /*completed */ {
if s.canceledWrite || s.finishedWriting {
return false, nil
return false
}
s.canceledWrite = true
s.cancelWriteErr = writeErr
@ -267,7 +266,7 @@ func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, wr
})
// TODO(#991): cancel retransmissions for this stream
s.ctxCancel()
return true, nil
return true
}
func (s *sendStream) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) {
@ -295,9 +294,7 @@ func (s *sendStream) handleStopSendingFrameImpl(frame *wire.StopSendingFrame) bo
errorCode: frame.ErrorCode,
error: fmt.Errorf("Stream %d was reset with error code %d", s.streamID, frame.ErrorCode),
}
errorCode := errorCodeStopping
completed, _ := s.cancelWriteImpl(errorCode, writeErr)
return completed
return s.cancelWriteImpl(errorCodeStopping, writeErr)
}
func (s *sendStream) Context() context.Context {