]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: handle SetDeadline to time.Now() in Plan 9
authormiller <millerresearch@gmail.com>
Thu, 18 May 2023 09:17:42 +0000 (10:17 +0100)
committerGopher Robot <gobot@golang.org>
Fri, 19 May 2023 17:10:57 +0000 (17:10 +0000)
The implementation of SetDeadline in Plan 9 begins by calculating
d = the offset of the requested deadline from time.Now(). If d > 0,
a timer is set to interrupt future I/O. If d < 0, the channel is
flagged to prevent future I/O and any current I/O is cancelled.
But if d = 0, nothing happens and the deadline isn't set.

The d = 0 case should be handled the same as d < 0.

Fixes #60282
Fixes #52896

Change-Id: Id8167db3604db1c129d99376fa78a3da75417d20
Reviewed-on: https://go-review.googlesource.com/c/go/+/496137
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/internal/poll/fd_plan9.go

index 2cfc5eec26b245a39152c0bf1c0372d6625ac448..7cc178a9d5a420196c7f6cced4eb116835f70a3c 100644 (file)
@@ -171,7 +171,7 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error {
                        fd.wtimer = timer
                }
        }
-       if !t.IsZero() && d < 0 {
+       if !t.IsZero() && d <= 0 {
                // Interrupt current I/O operation
                if mode == 'r' || mode == 'r'+'w' {
                        fd.rtimedout = true