浏览代码

Merge pull request #39445 from lzhfromustc/master

ioutils: Fixed a potential data race in bytespipe
Michael Crosby 6 年之前
父节点
当前提交
a43a2ed746
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      pkg/ioutils/bytespipe.go

+ 2 - 1
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 {