From bb52187805839fd4f12e0c458b2ac31e0a30e8ff Mon Sep 17 00:00:00 2001 From: Achille Roussel Date: Sun, 28 May 2017 23:03:10 -0700 Subject: [PATCH] add comment --- conn.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conn.go b/conn.go index e572a8775..3ed1d2689 100644 --- a/conn.go +++ b/conn.go @@ -373,6 +373,13 @@ func (c *Conn) ReadAt(b []byte, offset int64) (int, int64, error) { if n > len(b) { n, err = len(b), io.ErrShortBuffer } else if n == 0 && time.Now().After(adjustedDeadline) { + // Because we use the adjusted deadline we could end up returning + // before the actual deadline occurred. This is necessary otherwise + // timing out the connection for read could end up leaving it in an + // unpredictable state, which would require closing it. + // This design decision was main to maximize the changes of keeping + // the connection open, the trade off being to lose precision on the + // read deadline management. err = RequestTimedOut } }