io: Avoid race condition in pipe.
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
http://codereview.appspot.com/1682048

apparentlymart/golang,h8liu/golang,ssrl/go,apparentlymart/golang,pombredanne/go-deleteme,nightlyone/golang,nightlyone/golang,h8liu/golang,pombredanne/go-deleteme,pombredanne/go-deleteme,h8liu/golang,apparentlymart/golang,tv42/old-go,ssrl/go,ssrl/go,ssrl/go,bdwalton/debian-golang,h8liu/golang,apparentlymart/golang,dsriram/golang,tv42/old-go,tv42/old-go,tv42/old-go,h8liu/golang,tianon/debian-golang,dsriram/golang,gnanderson/go,dsriram/golang,apparentlymart/golang,pombredanne/go-deleteme,nightlyone/golang,ssrl/go,tv42/old-go,tianon/debian-golang,apparentlymart/golang,bdwalton/debian-golang,gnanderson/go,gnanderson/go,h8liu/golang,apparentlymart/golang,gnanderson/go,gnanderson/go,gnanderson/go,dsriram/golang,gnanderson/go,nightlyone/golang,dsriram/golang,bdwalton/debian-golang,bdwalton/debian-golang,pombredanne/go-deleteme,nightlyone/golang,bdwalton/debian-golang,bdwalton/debian-golang,dsriram/golang,tv42/old-go,bdwalton/debian-golang,pombredanne/go-deleteme,tianon/debian-golang,tianon/debian-golang,tianon/debian-golang,tv42/old-go,pombredanne/go-deleteme,h8liu/golang,tianon/debian-golang,bdwalton/debian-golang,nightlyone/golang,tianon/debian-golang,tianon/debian-golang,ssrl/go,dsriram/golang,ssrl/go,nightlyone/golang