Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused error return value in Stream.processFlags #39

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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