Skip to content

Commit

Permalink
fix(net): Buf use Mutex (AlistGo#5823)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Hsu <[email protected]>
  • Loading branch information
2 people authored and EtherealAO committed Apr 12, 2024
1 parent 908dd6b commit 7b5df6d
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 7b5df6d

Please sign in to comment.