From c2479f6ebf288fe8660ea64f51ac80cfdda3011d Mon Sep 17 00:00:00 2001 From: lzhfromutsc Date: Mon, 1 Jul 2019 11:38:38 -0700 Subject: [PATCH] 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 --- pkg/ioutils/bytespipe.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/ioutils/bytespipe.go b/pkg/ioutils/bytespipe.go index d4bbf3c9dc..87514b643d 100644 --- a/pkg/ioutils/bytespipe.go +++ b/pkg/ioutils/bytespipe.go @@ -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 {