net: clarify that Conn deadlines also affect currently-blocked I/O

All implementations have always implemented this behavior, it's
tested, and it's depended on by other packages. (notably, by net/http)

The one exception is Plan 9 which doesn't support I/O deadlines at all
(tracked in #11932). As a result, a bunch of tests fail on plan9
(#7237). But once Plan 9 adds I/O deadline support, it'll also need
this behavior.

Change-Id: Idb71767f0c99279c66dce29f7bdc78ef467e47aa
Reviewed-on: https://go-review.googlesource.com/30164
Reviewed-by: Sam Whited <sam@samwhited.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2016-10-01 20:28:09 -07:00
parent 99339dd445
commit 5f36e9a306

View file

@ -137,8 +137,9 @@ type Conn interface {
//
// A deadline is an absolute time after which I/O operations
// fail with a timeout (see type Error) instead of
// blocking. The deadline applies to all future I/O, not just
// the immediately following call to Read or Write.
// blocking. The deadline applies to all future and pending
// I/O, not just the immediately following call to Read or
// Write.
//
// An idle timeout can be implemented by repeatedly extending
// the deadline after successful Read or Write calls.
@ -146,11 +147,13 @@ type Conn interface {
// A zero value for t means I/O operations will not time out.
SetDeadline(t time.Time) error
// SetReadDeadline sets the deadline for future Read calls.
// SetReadDeadline sets the deadline for future Read calls
// and any currently-blocked Read call.
// A zero value for t means Read will not time out.
SetReadDeadline(t time.Time) error
// SetWriteDeadline sets the deadline for future Write calls.
// SetWriteDeadline sets the deadline for future Write calls
// and any currently-blocked Write call.
// Even if write times out, it may return n > 0, indicating that
// some of the data was successfully written.
// A zero value for t means Write will not time out.