Skip to content

Commit

Permalink
remove unused error return value in Stream.processFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Feb 16, 2021
1 parent b6118a4 commit 918ecce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
7 changes: 1 addition & 6 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,7 @@ func (s *Session) handleStreamMessage(hdr header) error {

// Check if this is a window update
if hdr.MsgType() == typeWindowUpdate {
if err := stream.incrSendWindow(hdr, flags); err != nil {
if sendErr := s.sendMsg(s.goAway(goAwayProtoErr), nil, nil); sendErr != nil {
s.logger.Printf("[WARN] yamux: failed to send go away: %v", sendErr)
}
return err
}
stream.incrSendWindow(hdr, flags)
return nil
}

Expand Down
20 changes: 5 additions & 15 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ func (s *Stream) sendWindowUpdate() error {

// Send the header
hdr := encode(typeWindowUpdate, flags, s.id, delta)
if err := s.session.sendMsg(hdr, nil, nil); err != nil {
return err
}
return nil
return s.session.sendMsg(hdr, nil, nil)
}

// sendClose is used to send a FIN
Expand Down Expand Up @@ -375,7 +372,7 @@ func (s *Stream) cleanup() {

// processFlags is used to update the state of the stream
// based on set flags, if any. Lock must be held
func (s *Stream) processFlags(flags uint16) error {
func (s *Stream) processFlags(flags uint16) {
// Close the stream without holding the state lock
closeStream := false
defer func() {
Expand Down Expand Up @@ -414,7 +411,6 @@ func (s *Stream) processFlags(flags uint16) error {
closeStream = true
s.notifyWaiting()
}
return nil
}

// notifyWaiting notifies all the waiting channels
Expand All @@ -424,22 +420,16 @@ func (s *Stream) notifyWaiting() {
}

// incrSendWindow updates the size of our send window
func (s *Stream) incrSendWindow(hdr header, flags uint16) error {
if err := s.processFlags(flags); err != nil {
return err
}

func (s *Stream) incrSendWindow(hdr header, flags uint16) {
s.processFlags(flags)
// Increase window, unblock a sender
atomic.AddUint32(&s.sendWindow, hdr.Length())
asyncNotify(s.sendNotifyCh)
return nil
}

// readData is used to handle a data frame
func (s *Stream) readData(hdr header, flags uint16, conn io.Reader) error {
if err := s.processFlags(flags); err != nil {
return err
}
s.processFlags(flags)

// Check that our recv window is not exceeded
length := hdr.Length()
Expand Down

0 comments on commit 918ecce

Please sign in to comment.