]> Cypherpunks repositories - gostls13.git/commit
io: Avoid race condition in pipe.
authorIan Lance Taylor <iant@golang.org>
Wed, 30 Jun 2010 20:14:46 +0000 (13:14 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 30 Jun 2010 20:14:46 +0000 (13:14 -0700)
commit7c1be45f5809169393eb19404ddd73fb4bf60e49
tree7f6c21e5c44bd35f570e80439eb6bdc19415bc6e
parentd3c3c15b1769c7167fb4188dbdb95b8f1d24c5e5
io: Avoid race condition in pipe.

One goroutine started up and was waiting in rw.  Then another
goroutine decided to close the pipe.  The closing goroutine
stalled calling p.io.Lock() in pipeHalf.close.  (This happened
in gccgo).  If the closing goroutine had been able to set the
ioclosed flag, it would have gone on to tell the runner that
the pipe was closed, which would then send an EINVAL to the
goroutine sleeping in rw.  Unlocking p.io before sleeping in
rw avoids the race.

R=rsc, rsc1
CC=golang-dev
https://golang.org/cl/1682048
src/pkg/io/pipe.go