aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2020-02-16 12:01:02 +1100
committerIan Lance Taylor <iant@golang.org>2020-03-25 20:42:50 +0000
commit74870669fc1d20ba44a32fd5e40fd3f3d7311a02 (patch)
tree2299c4880358952eee92282576f51511b9d7e018
parentca153f4db7e40f151dbd02081c0814194342428a (diff)
downloadgo-74870669fc1d20ba44a32fd5e40fd3f3d7311a02.tar.gz
go-74870669fc1d20ba44a32fd5e40fd3f3d7311a02.zip
[release-branch.go1.14] runtime: ignore error returned by PowerRegisterSuspendResumeNotification
It appears that PowerRegisterSuspendResumeNotification is not supported when running inside Docker - see issues #35447, #36557 and #37149. Our current code relies on error number to determine Docker environment. But we already saw PowerRegisterSuspendResumeNotification return ERROR_FILE_NOT_FOUND, ERROR_INVALID_PARAMETERS and ERROR_ACCESS_DENIED (see issues above). So this approach is not sustainable. Just ignore PowerRegisterSuspendResumeNotification returned error. For #37149 Fixes #37699 Change-Id: I2beba9d45cdb8c1efac5e974e747827a6261915a Reviewed-on: https://go-review.googlesource.com/c/go/+/219657 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> (cherry picked from commit d467f3bbc9c76805ae16ab1924c28ec3be487875) Reviewed-on: https://go-review.googlesource.com/c/go/+/224586 Run-TryBot: Ian Lance Taylor <iant@golang.org>
-rw-r--r--src/runtime/os_windows.go23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go
index bddc25729a..7f4ce14ef1 100644
--- a/src/runtime/os_windows.go
+++ b/src/runtime/os_windows.go
@@ -294,9 +294,7 @@ func loadOptionalSyscalls() {
func monitorSuspendResume() {
const (
- _DEVICE_NOTIFY_CALLBACK = 2
- _ERROR_FILE_NOT_FOUND = 2
- _ERROR_INVALID_PARAMETERS = 87
+ _DEVICE_NOTIFY_CALLBACK = 2
)
type _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS struct {
callback uintptr
@@ -323,25 +321,8 @@ func monitorSuspendResume() {
callback: compileCallback(*efaceOf(&fn), true),
}
handle := uintptr(0)
- ret := stdcall3(powerRegisterSuspendResumeNotification, _DEVICE_NOTIFY_CALLBACK,
+ stdcall3(powerRegisterSuspendResumeNotification, _DEVICE_NOTIFY_CALLBACK,
uintptr(unsafe.Pointer(&params)), uintptr(unsafe.Pointer(&handle)))
- // This function doesn't use GetLastError(), so we use the return value directly.
- switch ret {
- case 0:
- return // Successful, nothing more to do.
- case _ERROR_FILE_NOT_FOUND:
- // Systems without access to the suspend/resume notifier
- // also have their clock on "program time", and therefore
- // don't want or need this anyway.
- return
- case _ERROR_INVALID_PARAMETERS:
- // This is seen when running in Windows Docker.
- // See issue 36557.
- return
- default:
- println("runtime: PowerRegisterSuspendResumeNotification failed with errno=", ret)
- throw("runtime: PowerRegisterSuspendResumeNotification failure")
- }
}
//go:nosplit