Skip to content

Commit

Permalink
unix: fix EINTR check in TestClockNanosleep
Browse files Browse the repository at this point in the history
err == EINTR needs to be checked before err != nil for the interrupted
syscall to be retried properly.

Follow-up for CL 207285

Updates golang/go#35622

Change-Id: I0f8c1a75eb96e11aaba284eb75716db044257cbd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/207290
Run-TryBot: Tobias Klauser <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
tklauser authored and bradfitz committed Nov 18, 2019
1 parent 81af739 commit 6254a7c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions unix/syscall_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,11 @@ func TestClockNanosleep(t *testing.T) {
until := start.Add(delay)
abs := unix.NsecToTimespec(until.UnixNano())
err := unix.ClockNanosleep(unix.CLOCK_REALTIME, unix.TIMER_ABSTIME, &abs, nil)
if err != nil {
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) = %v", &abs, until, err)
} else if err == unix.EINTR {
if err == unix.EINTR {
t.Logf("ClockNanosleep interrupted after %v", time.Since(start))
continue
} else if err != nil {
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) = %v", &abs, until, err)
} else if slept := time.Since(start); slept < delay {
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) slept only %v", &abs, until, slept)
}
Expand Down

0 comments on commit 6254a7c

Please sign in to comment.