Skip to content

Commit

Permalink
fix race in write timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Aug 27, 2024
1 parent ea5605b commit 4aed194
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4aed194

Please sign in to comment.