Skip to content

Commit

Permalink
fix a potential race in closing stream.die
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Sep 22, 2016
1 parent bc68dab commit 9f2b528
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ func (s *Stream) Close() error {
func (s *Stream) sessionClose() {
s.dieLock.Lock()
defer s.dieLock.Unlock()
close(s.die)

select {
case <-s.die:
default:
close(s.die)
}
}

// pushBytes a slice into buffer
Expand Down

0 comments on commit 9f2b528

Please sign in to comment.