diff --git a/const.go b/const.go index ba33f7c..7062231 100644 --- a/const.go +++ b/const.go @@ -24,8 +24,8 @@ func (ye *Error) Temporary() bool { } type GoAwayError struct { - Remote bool ErrorCode uint32 + Remote bool } func (e *GoAwayError) Error() string { diff --git a/session.go b/session.go index e31bef4..204b168 100644 --- a/session.go +++ b/session.go @@ -536,13 +536,14 @@ func (s *Session) send() { if err := s.sendLoop(); err != nil { // Prefer the recvLoop error over the sendLoop error. The receive loop might have the error code // received in a GoAway frame received just before the TCP RST that closed the sendLoop - // - // Take the shutdownLock to avoid closing the connection concurrently with a Close call. s.shutdownLock.Lock() - s.conn.Close() - <-s.recvDoneCh - if _, ok := s.recvErr.(*GoAwayError); ok { - err = s.recvErr + if s.shutdownErr == nil { + s.conn.Close() + <-s.recvDoneCh + if _, ok := s.recvErr.(*GoAwayError); ok { + err = s.recvErr + } + s.shutdownErr = err } s.shutdownLock.Unlock() s.close(err, false, 0)