]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.11] runtime: in semasleep, subtract time spent so far from timeout
authorKeith Randall <khr@golang.org>
Wed, 5 Sep 2018 21:36:20 +0000 (14:36 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 7 Sep 2018 18:58:38 +0000 (18:58 +0000)
commit57534891d446b8ef5e0ebf62c027beb7d6a55f67
tree1804be89e92cecf36de89475bb56c3041bfff6a9
parentebf5d985d1a51440d19bd6ac6a43654179527fdc
[release-branch.go1.11] runtime: in semasleep, subtract time spent so far from timeout

When pthread_cond_timedwait_relative_np gets a spurious wakeup
(due to a signal, typically), we used to retry with the same
relative timeout. That's incorrect, we should lower the timeout
by the time we've spent in this function so far.

In the worst case, signals come in and cause spurious wakeups
faster than the timeout, causing semasleep to never time out.

Also fix nacl and netbsd while we're here. They have similar issues.

Fixes #27521

Change-Id: I6601e120e44a4b8ef436eef75a1e7c8cf1d39e39
Reviewed-on: https://go-review.googlesource.com/133655
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 2bf1370f4369d75f4fffffc6fc05722bce13481b)
Reviewed-on: https://go-review.googlesource.com/134096
src/runtime/os_darwin.go
src/runtime/os_nacl.go
src/runtime/os_netbsd.go