Skip to content

Commit 4aed194

Browse files
committed
fix race in write timeout
1 parent ea5605b commit 4aed194

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

session.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,14 @@ func (s *Session) send() {
536536
if err := s.sendLoop(); err != nil {
537537
// Prefer the recvLoop error over the sendLoop error. The receive loop might have the error code
538538
// received in a GoAway frame received just before the TCP RST that closed the sendLoop
539-
//
540-
// Take the shutdownLock to avoid closing the connection concurrently with a Close call.
541539
s.shutdownLock.Lock()
542-
s.conn.Close()
543-
<-s.recvDoneCh
544-
if _, ok := s.recvErr.(*GoAwayError); ok {
545-
err = s.recvErr
540+
if s.shutdownErr == nil {
541+
s.conn.Close()
542+
<-s.recvDoneCh
543+
if _, ok := s.recvErr.(*GoAwayError); ok {
544+
err = s.recvErr
545+
}
546+
s.shutdownErr = err
546547
}
547548
s.shutdownLock.Unlock()
548549
s.close(err, false, 0)

0 commit comments

Comments
 (0)