parent
8020d42b10
commit
4448e08f5b
@ -449,7 +449,7 @@ type Buf struct {
|
|||||||
size int //expected size
|
size int //expected size
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
off int
|
off int
|
||||||
rw sync.RWMutex
|
rw sync.Mutex
|
||||||
//notify chan struct{}
|
//notify chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,9 +480,9 @@ func (br *Buf) Read(p []byte) (n int, err error) {
|
|||||||
if br.off >= br.size {
|
if br.off >= br.size {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
br.rw.RLock()
|
br.rw.Lock()
|
||||||
n, err = br.buffer.Read(p)
|
n, err = br.buffer.Read(p)
|
||||||
br.rw.RUnlock()
|
br.rw.Unlock()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
br.off += n
|
br.off += n
|
||||||
return n, err
|
return n, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user