Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: ignore error returned by PowerRegisterSuspendResumeNotification #1

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions src/runtime/os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down