diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-27 06:46:16 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-30 14:20:49 +0000 |
commit | d85072ff86e61752fb89363d7c929c850e0a8a8d (patch) | |
tree | 8dd9af2e05dd9b8826b8faf6eadb643281e362a4 /src/runtime/syscall_windows.go | |
parent | 8c5de667d3b1349a3058e4c57b01f0309502a118 (diff) | |
download | go-d85072ff86e61752fb89363d7c929c850e0a8a8d.tar.gz go-d85072ff86e61752fb89363d7c929c850e0a8a8d.zip |
runtime: monitor for suspend/resume to kick timeouts
Starting in Windows 8, the wait functions don't take into account
suspend time, even though the monotonic counters do. This results in
timer buckets stalling on resume. Therefore, this commit makes it so
that on resume, we return from the wait functions and recalculate the
amount of time left to wait.
Fixes: #31528
Change-Id: I0db02cc72188cb620954e87a0180e0a3c83f4a56
Reviewed-on: https://go-review.googlesource.com/c/go/+/191957
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/runtime/syscall_windows.go')
-rw-r--r-- | src/runtime/syscall_windows.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/runtime/syscall_windows.go b/src/runtime/syscall_windows.go index 722a73d108..0e2fcfb02d 100644 --- a/src/runtime/syscall_windows.go +++ b/src/runtime/syscall_windows.go @@ -74,16 +74,18 @@ func compileCallback(fn eface, cleanstack bool) (code uintptr) { argsize += uintptrSize } - lock(&cbs.lock) - defer unlock(&cbs.lock) + lock(&cbs.lock) // We don't unlock this in a defer because this is used from the system stack. n := cbs.n for i := 0; i < n; i++ { if cbs.ctxt[i].gobody == fn.data && cbs.ctxt[i].isCleanstack() == cleanstack { - return callbackasmAddr(i) + r := callbackasmAddr(i) + unlock(&cbs.lock) + return r } } if n >= cb_max { + unlock(&cbs.lock) throw("too many callback functions") } @@ -99,7 +101,9 @@ func compileCallback(fn eface, cleanstack bool) (code uintptr) { cbs.ctxt[n] = c cbs.n++ - return callbackasmAddr(n) + r := callbackasmAddr(n) + unlock(&cbs.lock) + return r } const _LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 |