1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fixed the inconsistence and also a potential data race in pkg/ioutils/bytespipe.go: bp.closeErr is read/write 8 times; 7 out of 8 times it is protected by bp.mu.Lock(); 1 out of 8 times it is read without a Lock

Signed-off-by: lzhfromutsc <lzhfromustc@gmail.com>
This commit is contained in:
lzhfromutsc 2019-07-01 11:38:38 -07:00
parent e105a74c54
commit c2479f6ebf

View file

@ -128,8 +128,9 @@ func (bp *BytesPipe) Read(p []byte) (n int, err error) {
bp.mu.Lock()
if bp.bufLen == 0 {
if bp.closeErr != nil {
err := bp.closeErr
bp.mu.Unlock()
return 0, bp.closeErr
return 0, err
}
bp.wait.Wait()
if bp.bufLen == 0 && bp.closeErr != nil {