]> Cypherpunks repositories - gostls13.git/commit
net: implement deadline functionality on Pipe
authorJoe Tsai <joetsai@digital-static.net>
Fri, 24 Feb 2017 01:13:09 +0000 (17:13 -0800)
committerJoe Tsai <thebrokentoaster@gmail.com>
Wed, 11 Oct 2017 20:00:52 +0000 (20:00 +0000)
commite2dd8ca946be884bb877e074a21727f1a685a706
tree92f0599632a6a20b376e5c3f2b0c7d1d57de3605
parent7dcd33302a8ce1c6ae5697ad85039684723cbdcc
net: implement deadline functionality on Pipe

Implement deadline functionality on Pipe so that it properly implements
the semantics of the Conn interface. This aids usages of Pipe (often in
unit tests) with a more realistic and complete implementation.

The new implementation avoids a dependency on a io.Pipe since it is
impossible to keep the prior semantics of synchronous reads and writes
while also trying to implement cancelation over an io.{Reader,Writer}
that fundamentally has no cancelation support.

The fact that net.Pipe is synchronous (and documented as such)
is unfortunate because no realistic network connection is synchronous.
Instead real networks introduces a read and write buffer of some sort.
However, we do not change the semantics for backwards compatibility.

The approach taken does not leave any long-running goroutines,
meaning that tests that never call Close will not cause a resource leak.

Fixes #18170

Change-Id: I5140b1f289a0a49fb2d485f031b5aa0ee99ecc30
Reviewed-on: https://go-review.googlesource.com/37402
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/pipe.go
src/net/pipe_test.go