Commit 40d8c3d3 authored by Wèi Cōngruì's avatar Wèi Cōngruì Committed by Ian Lance Taylor

internal/poll: fix deadlock in Write if len(buf) > maxRW

fd.l.Lock shouldn't be called in a loop.

Change-Id: I3afbc184aa06a60175c9a39319985b5810ecb144
Reviewed-on: https://go-review.googlesource.com/c/go/+/165598
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent a60b56ad
......@@ -673,6 +673,10 @@ func (fd *FD) Write(buf []byte) (int, error) {
return 0, err
}
defer fd.writeUnlock()
if fd.isFile {
fd.l.Lock()
defer fd.l.Unlock()
}
ntotal := 0
for len(buf) > 0 {
......@@ -683,8 +687,6 @@ func (fd *FD) Write(buf []byte) (int, error) {
var n int
var err error
if fd.isFile {
fd.l.Lock()
defer fd.l.Unlock()
switch fd.kind {
case kindConsole:
n, err = fd.writeConsole(b)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment