Skip to content

Commit

Permalink
fix: avoid returning accept errors
Browse files Browse the repository at this point in the history
Instead, wait for shutdown.
  • Loading branch information
Stebalien committed May 28, 2019
1 parent 136a0f4 commit 7527c51
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,18 @@ func (s *Session) Accept() (net.Conn, error) {
// AcceptStream is used to block until the next available stream
// is ready to be accepted.
func (s *Session) AcceptStream() (*Stream, error) {
select {
case stream := <-s.acceptCh:
if err := stream.sendWindowUpdate(); err != nil {
return nil, err
for {
select {
case stream := <-s.acceptCh:
if err := stream.sendWindowUpdate(); err != nil {
// don't return accept errors.
s.logger.Printf("[WARN] error sending window update before accepting: %s", err)
continue
}
return stream, nil
case <-s.shutdownCh:
return nil, s.shutdownErr
}
return stream, nil
case <-s.shutdownCh:
return nil, s.shutdownErr
}
}

Expand Down

0 comments on commit 7527c51

Please sign in to comment.