Skip to content

Commit

Permalink
Make sure to release lock when acquiring and connection is closed.
Browse files Browse the repository at this point in the history
Closes #205
  • Loading branch information
nhooyr committed Feb 28, 2020
1 parent c62c0dc commit ff876f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conn_notjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,11 @@ func (m *mu) lock(ctx context.Context) error {
case m.ch <- struct{}{}:
// To make sure the connection is certainly alive.
// As it's possible the send on m.ch was selected
// the receive on closed.
// over the receive on closed.
select {
case <-m.c.closed:
// Make sure to release.
m.unlock()
return m.c.closeErr
default:
}
Expand Down

0 comments on commit ff876f6

Please sign in to comment.