mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
net/nettest: de-flake tests on Windows
Windows has a low resolution timer. Some of the tests assumed that unblock takes effect immediately. Consider: t := time.Now() elapsed := time.Now().After(t) It seems plausible that elapsed should always be true. However, with a low resolution timer, that might fail. Change time.Now().After to !time.Now().Before, so that unblocking always takes effect immediately. Fixes #873.
This commit is contained in:
parent
a64d06f15c
commit
7c1a9e8616
@ -60,7 +60,7 @@ func (p *Pipe) Read(b []byte) (n int, err error) {
|
|||||||
for {
|
for {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
closed := p.closed
|
closed := p.closed
|
||||||
timedout := !p.readTimeout.IsZero() && time.Now().After(p.readTimeout)
|
timedout := !p.readTimeout.IsZero() && !time.Now().Before(p.readTimeout)
|
||||||
blocked := p.blocked
|
blocked := p.blocked
|
||||||
if !closed && !timedout && len(p.buf) > 0 {
|
if !closed && !timedout && len(p.buf) > 0 {
|
||||||
n2 := copy(b, p.buf)
|
n2 := copy(b, p.buf)
|
||||||
@ -99,7 +99,7 @@ func (p *Pipe) Write(b []byte) (n int, err error) {
|
|||||||
for {
|
for {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
closed := p.closed
|
closed := p.closed
|
||||||
timedout := !p.writeTimeout.IsZero() && time.Now().After(p.writeTimeout)
|
timedout := !p.writeTimeout.IsZero() && !time.Now().Before(p.writeTimeout)
|
||||||
blocked := p.blocked
|
blocked := p.blocked
|
||||||
if !closed && !timedout {
|
if !closed && !timedout {
|
||||||
n2 := len(b)
|
n2 := len(b)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user