Skip to content

Commit

Permalink
Merge pull request #34 from erikdubbelboer/recvrace
Browse files Browse the repository at this point in the history
Fix race for recvBuf
  • Loading branch information
slackpad committed Jul 20, 2016
2 parents d2be601 + f30b49b commit d1caa6c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ START:
case streamRemoteClose:
fallthrough
case streamClosed:
s.recvLock.Lock()
if s.recvBuf == nil || s.recvBuf.Len() == 0 {
s.recvLock.Unlock()
s.stateLock.Unlock()
return 0, io.EOF
}
s.recvLock.Unlock()
case streamReset:
s.stateLock.Unlock()
return 0, ErrConnectionReset
Expand Down

0 comments on commit d1caa6c

Please sign in to comment.