mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 21:57:36 +03:00
Fix a data race in stream.Read
This commit is contained in:
parent
ff42100f1b
commit
a7c60e3229
1 changed files with 4 additions and 1 deletions
|
@ -69,8 +69,11 @@ func newStream(StreamID protocol.StreamID, onData func(), onReset func(protocol.
|
|||
|
||||
// Read implements io.Reader. It is not thread safe!
|
||||
func (s *stream) Read(p []byte) (int, error) {
|
||||
s.mutex.Lock()
|
||||
err := s.err
|
||||
s.mutex.Unlock()
|
||||
if s.cancelled.Get() || s.resetLocally.Get() {
|
||||
return 0, s.err
|
||||
return 0, err
|
||||
}
|
||||
if s.finishedReading.Get() {
|
||||
return 0, io.EOF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue