1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/daemon_windows.go
Brian Goff 20f99a8634 TestDaemonDiscoveryBackendConfigReload behavior
`TestDaemonDiscoveryBackendConfigReload` was doing some wierd things
with files, creating a file (directly in `./integration-cli`), removing
it, then creating a new file.
This is just weird, so fixed it to use a single file, file will go into
a temp dir so it doesn't pollute integration-cli.

It was also blindly sending a SIGHUP to the daemon process then sleeping
for 3 seconds.  This is racey, and slow.
Change this to look for the daemon-reload event in the event stream.
Reload logic is moved to a separate function and blocks (w/ a timeout)
waiting for the reload event to fire.

Runtime of the test is now ~0.5s on my machine, where as it was a
minimum of 3s due to the `time.Sleep` before.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-08-26 11:02:04 -04:00

47 lines
1.1 KiB
Go

package main
import (
"fmt"
"strconv"
"syscall"
"unsafe"
)
func openEvent(desiredAccess uint32, inheritHandle bool, name string, proc *syscall.LazyProc) (handle syscall.Handle, err error) {
namep, _ := syscall.UTF16PtrFromString(name)
var _p2 uint32
if inheritHandle {
_p2 = 1
}
r0, _, e1 := proc.Call(uintptr(desiredAccess), uintptr(_p2), uintptr(unsafe.Pointer(namep)))
handle = syscall.Handle(r0)
if handle == syscall.InvalidHandle {
err = e1
}
return
}
func pulseEvent(handle syscall.Handle, proc *syscall.LazyProc) (err error) {
r0, _, _ := proc.Call(uintptr(handle))
if r0 != 0 {
err = syscall.Errno(r0)
}
return
}
func signalDaemonDump(pid int) {
modkernel32 := syscall.NewLazyDLL("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 {
return
}
pulseEvent(h2, procPulseEvent)
}
func signalDaemonReload(pid int) error {
return fmt.Errorf("daemon reload not supported")
}