Skip to content

Commit

Permalink
remove the recvLock in the stream
Browse files Browse the repository at this point in the history
Concurrent use of an io.Reader is not valid.
  • Loading branch information
marten-seemann committed Feb 16, 2021
1 parent 4847d7c commit a87f725
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type Stream struct {
writeState, readState halfStreamState
stateLock sync.Mutex

recvLock sync.Mutex
recvBuf segmentedBuffer

sendLock sync.Mutex
Expand Down Expand Up @@ -99,15 +98,12 @@ START:
}

// If there is no data available, block
s.recvLock.Lock()
if s.recvBuf.Len() == 0 {
s.recvLock.Unlock()
goto WAIT
}

// Read any bytes
n, _ = s.recvBuf.Read(b)
s.recvLock.Unlock()

// Send a window update potentially
err = s.sendWindowUpdate()
Expand Down Expand Up @@ -448,7 +444,7 @@ func (s *Stream) readData(hdr header, flags uint16, conn io.Reader) error {
s.session.logger.Printf("[ERR] yamux: Failed to read stream data: %v", err)
return err
}
// Unblock any readers
// Unblock the reader
asyncNotify(s.recvNotifyCh)
return nil
}
Expand Down

0 comments on commit a87f725

Please sign in to comment.