Use event functions from golang.org/x/sys/windows
Use CreateEvent, OpenEvent (which both map to the respective *EventW function) and PulseEvent from golang.org/x/sys instead of local copies. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Upstream-commit: e942513ac46656c3f54cd103e990e2b7bd5c2b14 Component: engine
This commit is contained in:
@@ -3,47 +3,19 @@ package daemon
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-check/check"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func openEvent(desiredAccess uint32, inheritHandle bool, name string, proc *windows.LazyProc) (handle windows.Handle, err error) {
|
||||
namep, _ := windows.UTF16PtrFromString(name)
|
||||
var _p2 uint32
|
||||
if inheritHandle {
|
||||
_p2 = 1
|
||||
}
|
||||
r0, _, e1 := proc.Call(uintptr(desiredAccess), uintptr(_p2), uintptr(unsafe.Pointer(namep)))
|
||||
handle = windows.Handle(r0)
|
||||
if handle == windows.InvalidHandle {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func pulseEvent(handle windows.Handle, proc *windows.LazyProc) (err error) {
|
||||
r0, _, _ := proc.Call(uintptr(handle))
|
||||
if r0 != 0 {
|
||||
err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SignalDaemonDump sends a signal to the daemon to write a dump file
|
||||
func SignalDaemonDump(pid int) {
|
||||
modkernel32 := windows.NewLazySystemDLL("kernel32.dll")
|
||||
procOpenEvent := modkernel32.NewProc("OpenEventW")
|
||||
procPulseEvent := modkernel32.NewProc("PulseEvent")
|
||||
|
||||
ev := "Global\\docker-daemon-" + strconv.Itoa(pid)
|
||||
h2, _ := openEvent(0x0002, false, ev, procOpenEvent)
|
||||
if h2 == 0 {
|
||||
ev, _ := windows.UTF16PtrFromString("Global\\docker-daemon-" + strconv.Itoa(pid))
|
||||
h2, err := windows.OpenEvent(0x0002, false, ev)
|
||||
if h2 == 0 || err != nil {
|
||||
return
|
||||
}
|
||||
pulseEvent(h2, procPulseEvent)
|
||||
windows.PulseEvent(h2)
|
||||
}
|
||||
|
||||
func signalDaemonReload(pid int) error {
|
||||
|
||||
Reference in New Issue
Block a user