Skip to content

Commit

Permalink
fix(net): Buf use Mutex (#5823)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Hsu <[email protected]>
  • Loading branch information
rammiah and xhofe authored Jan 5, 2024
1 parent 8020d42 commit 4448e08
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/net/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ type Buf struct {
size int //expected size
ctx context.Context
off int
rw sync.RWMutex
rw sync.Mutex
//notify chan struct{}
}

Expand Down Expand Up @@ -480,9 +480,9 @@ func (br *Buf) Read(p []byte) (n int, err error) {
if br.off >= br.size {
return 0, io.EOF
}
br.rw.RLock()
br.rw.Lock()
n, err = br.buffer.Read(p)
br.rw.RUnlock()
br.rw.Unlock()
if err == nil {
br.off += n
return n, err
Expand Down

0 comments on commit 4448e08

Please sign in to comment.