Skip to content

Commit 7487066

Browse files
alexbrainmanianlancetaylor
authored andcommitted
[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 <[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/+/224586 Run-TryBot: Ian Lance Taylor <[email protected]>
1 parent ca153f4 commit 7487066

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
@@ -294,9 +294,7 @@ func loadOptionalSyscalls() {
294294

295295
func monitorSuspendResume() {
296296
const (
297-
_DEVICE_NOTIFY_CALLBACK = 2
298-
_ERROR_FILE_NOT_FOUND = 2
299-
_ERROR_INVALID_PARAMETERS = 87
297+
_DEVICE_NOTIFY_CALLBACK = 2
300298
)
301299
type _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS struct {
302300
callback uintptr
@@ -323,25 +321,8 @@ func monitorSuspendResume() {
323321
callback: compileCallback(*efaceOf(&fn), true),
324322
}
325323
handle := uintptr(0)
326-
ret := stdcall3(powerRegisterSuspendResumeNotification, _DEVICE_NOTIFY_CALLBACK,
324+
stdcall3(powerRegisterSuspendResumeNotification, _DEVICE_NOTIFY_CALLBACK,
327325
uintptr(unsafe.Pointer(&params)), uintptr(unsafe.Pointer(&handle)))
328-
// This function doesn't use GetLastError(), so we use the return value directly.
329-
switch ret {
330-
case 0:
331-
return // Successful, nothing more to do.
332-
case _ERROR_FILE_NOT_FOUND:
333-
// Systems without access to the suspend/resume notifier
334-
// also have their clock on "program time", and therefore
335-
// don't want or need this anyway.
336-
return
337-
case _ERROR_INVALID_PARAMETERS:
338-
// This is seen when running in Windows Docker.
339-
// See issue 36557.
340-
return
341-
default:
342-
println("runtime: PowerRegisterSuspendResumeNotification failed with errno=", ret)
343-
throw("runtime: PowerRegisterSuspendResumeNotification failure")
344-
}
345326
}
346327

347328
//go:nosplit

0 commit comments

Comments
 (0)