diff --git a/src/pkg/io/pipe.go b/src/pkg/io/pipe.go index 79221bd497..898526921f 100644 --- a/src/pkg/io/pipe.go +++ b/src/pkg/io/pipe.go @@ -144,10 +144,11 @@ func (p *pipeHalf) rw(data []byte) (n int, err os.Error) { // Run i/o operation. // Check ioclosed flag under lock to make sure we're still allowed to do i/o. p.io.Lock() - defer p.io.Unlock() if p.ioclosed { + p.io.Unlock() return 0, os.EINVAL } + p.io.Unlock() p.c1 <- data res := <-p.c2 return res.n, res.err