From 7527c5108b3f5c4d983830da45ba34a49c167ab1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 27 May 2019 18:18:09 -0700 Subject: [PATCH] fix: avoid returning accept errors Instead, wait for shutdown. --- session.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/session.go b/session.go index 4af4c05..662efa0 100644 --- a/session.go +++ b/session.go @@ -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 } }