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>
Showing
Please
register
or
sign in
to comment