Skip to content
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.Write should not block when writing zero bytes #14139

Closed
jongillham opened this issue Jan 28, 2016 · 7 comments
Closed

io: PipeWriter.Write should not block when writing zero bytes #14139

jongillham opened this issue Jan 28, 2016 · 7 comments
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@jongillham
Copy link

io.PipeWriter.Write([]byte{}) blocks when no readers are waiting at the other end of the pipe. To unblock the pipe zero or more bytes must be read from io.PipeWriter.Read.

I expect io.PipeWriter.Write([]byte{}) to not ever block.

See https://groups.google.com/forum/#!topic/golang-nuts/nRPhBt0zoAM for the discussion.

See http://play.golang.org/p/MNSyKafKYf for an example.

@extemporalgenome
Copy link
Contributor

What's the behavior of network or stdio paired writes when there are no corresponding blocking readers? I figure it should emulate that behavior, whatever it is.

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Jan 28, 2016
@ianlancetaylor
Copy link
Member

There are uses for zero-byte writes, exactly to see whether there are readers, but since nothing is documented it seems unlikely that anybody is relying on it.

Whatever we decide, we should document the behavior.

@rsc
Copy link
Contributor

rsc commented May 18, 2016

io.Pipe preserves message boundaries. Writes and Reads are paired one to one (except when it requires multiple Reads to consume a single Write). Write should block when writing zero bytes, until a Read comes along and takes them.

@rsc rsc modified the milestones: Go1.8, Go1.7 May 18, 2016
@bradfitz
Copy link
Contributor

We have so many random rules for 0 byte reads & writes. I'll add this to my mental list of special cases. This might be fine behavior for a PipeFoo but it'd be really nice to define semantics for 0-byte operations on the io.Reader and io.Writer interfaces.

@quentinmit
Copy link
Contributor

@rsc Does that make this WAI? Or should we repurpose this issue to improve the documentation?

@quentinmit quentinmit added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 7, 2016
@bradfitz bradfitz added the Documentation Issues describing a change to documentation. label Oct 7, 2016
@bradfitz
Copy link
Contributor

bradfitz commented Oct 7, 2016

Yes, it sounds like documentation.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/31321 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 18, 2017
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

7 participants