-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io: PipeWriter allows Write after Close #5330
Labels
Milestone
Comments
If the above is not bug, the following should be bug:(if the above fixed by my code, the following code runs ok.) http://play.golang.org/p/JCQV4uN8GJ I write data 3 times, but I read 4 times. This issue can fixed by above code, otherwise, this code is also can fix it: io/pipe.go, line 42: change the code for { if p.rerr != nil { return 0, ErrClosedPipe } if p.data != nil { break } if p.werr != nil { return 0, p.werr } p.rwait.Wait() } to for { if p.rerr != nil { return 0, ErrClosedPipe } if p.werr != nil { return 0, p.werr } if p.data != nil { break } p.rwait.Wait() } |
I'm having trouble reproducing the problem you reported. I'm also having trouble figuring out if it is an issue. Please consider this slightly simplified example http://play.golang.org/p/Vhh0PoiEKq Status changed to WaitingForReply. |
http://play.golang.org/p/bXlyS33kEE package main import ( "fmt" "io" ) func main() { r, w := io.Pipe() go func() { w.Write([]byte("hello")) w.Close() w.Write([]byte("world")) }() buf := make([]byte, 100) for i := 0; i < 3; i++ { n, err := r.Read(buf) fmt.Printf("%q %v\n", buf[:n], err) } } "hello" <nil> "world" <nil> "" EOF Labels changed: added priority-later, go1.2, removed priority-triage. Status changed to Accepted. |
This issue was closed by revision 4be9385. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by xuxinhua1984:
The text was updated successfully, but these errors were encountered: