Skip to content

Commit d6224d3

Browse files
alexbrainmanianlancetaylor
authored andcommitted
[release-branch.go1.13] 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 #37230 Change-Id: I2beba9d45cdb8c1efac5e974e747827a6261915a Reviewed-on: https://go-review.googlesource.com/c/go/+/219657 Run-TryBot: Alex Brainman <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]> Reviewed-by: Jason A. Donenfeld <[email protected]> (cherry picked from commit d467f3b) Reviewed-on: https://go-review.googlesource.com/c/go/+/224585 Run-TryBot: Ian Lance Taylor <[email protected]>
1 parent 33554bc commit d6224d3

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/runtime/os_windows.go

+2-21
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,7 @@ func loadOptionalSyscalls() {
263263

264264
func monitorSuspendResume() {
265265
const (
266-
_DEVICE_NOTIFY_CALLBACK = 2
267-
_ERROR_FILE_NOT_FOUND = 2
268-
_ERROR_INVALID_PARAMETERS = 87
266+
_DEVICE_NOTIFY_CALLBACK = 2
269267
)
270268
type _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS struct {
271269
callback uintptr
@@ -292,25 +290,8 @@ func monitorSuspendResume() {
292290
callback: compileCallback(*efaceOf(&fn), true),
293291
}
294292
handle := uintptr(0)
295-
ret := stdcall3(powerRegisterSuspendResumeNotification, _DEVICE_NOTIFY_CALLBACK,
293+
stdcall3(powerRegisterSuspendResumeNotification, _DEVICE_NOTIFY_CALLBACK,
296294
uintptr(unsafe.Pointer(&params)), uintptr(unsafe.Pointer(&handle)))
297-
// This function doesn't use GetLastError(), so we use the return value directly.
298-
switch ret {
299-
case 0:
300-
return // Successful, nothing more to do.
301-
case _ERROR_FILE_NOT_FOUND:
302-
// Systems without access to the suspend/resume notifier
303-
// also have their clock on "program time", and therefore
304-
// don't want or need this anyway.
305-
return
306-
case _ERROR_INVALID_PARAMETERS:
307-
// This is seen when running in Windows Docker.
308-
// See issue 36557.
309-
return
310-
default:
311-
println("runtime: PowerRegisterSuspendResumeNotification failed with errno=", ret)
312-
throw("runtime: PowerRegisterSuspendResumeNotification failure")
313-
}
314295
}
315296

316297
//go:nosplit

0 commit comments

Comments
 (0)