Poll the nic on the sampler's cadence, and reboot rather than exit when a clean return reaches PID 1
This commit is contained in:
+4
-4
@@ -80,10 +80,10 @@ func sumFields(base string, fields []string) uint64 {
|
||||
|
||||
// A poll is an ioctl and a handful of sysfs attributes, each costing
|
||||
// microseconds of open and read, so it runs here rather than on the goroutine
|
||||
// that has a frame to draw every sixteen milliseconds. Off that path the
|
||||
// interval can be short enough that an unplugged cable shows up as a link error
|
||||
// while the hand is still on it.
|
||||
const nicInterval = 200 * time.Millisecond
|
||||
// that has a frame to draw every sixteen milliseconds. Off that path it can
|
||||
// match the sampler's cadence, so a link error lands on the panel as quickly
|
||||
// as a lost frame rather than stepping five times a second.
|
||||
const nicInterval = sampleInterval
|
||||
|
||||
type nicPoller struct {
|
||||
txBase string
|
||||
|
||||
@@ -535,6 +535,14 @@ func main() {
|
||||
if err := run(*aName, *bName, *nsPerM); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// A clean return is ctrl-alt-delete, which the kernel hands PID 1 as a
|
||||
// SIGINT. Exiting on it would panic the kernel over the reboot it was asking
|
||||
// for, so init asks for the reboot by name.
|
||||
if os.Getpid() == 1 {
|
||||
if err := unix.Reboot(unix.LINUX_REBOOT_CMD_RESTART); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user