From 2307f5006a290cebdb8b8868cd1e976bb107df97 Mon Sep 17 00:00:00 2001 From: Mantas Vidutis Date: Wed, 24 Apr 2019 07:21:02 -0700 Subject: [PATCH] review updates --- daemon.go | 14 ++++---------- trap_posix.go | 12 +++--------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/daemon.go b/daemon.go index 1a09541..cd19508 100644 --- a/daemon.go +++ b/daemon.go @@ -148,8 +148,8 @@ func (d *Daemon) listen() { } } -func clearUnixSockets(maddr ma.Multiaddr) error { - for _, subMaddr := range ma.Split(maddr) { +func clearUnixSockets(path ma.Multiaddr) error { + for _, subMaddr := range ma.Split(path) { if subMaddr.Protocols()[0].Code == ma.P_UNIX { socket, err := subMaddr.ValueForProtocol(ma.P_UNIX) if err != nil { @@ -168,18 +168,12 @@ func (d *Daemon) Close() error { return err } - listenMaddr := d.listener.Multiaddr() + listenAddr := d.listener.Multiaddr() if err := d.listener.Close(); err != nil { return err } - for _, maddr := range d.handlers { - if err := clearUnixSockets(maddr); err != nil { - return err - } - } - - if err := clearUnixSockets(listenMaddr); err != nil { + if err := clearUnixSockets(listenAddr); err != nil { return err } diff --git a/trap_posix.go b/trap_posix.go index 258ac22..c141a08 100644 --- a/trap_posix.go +++ b/trap_posix.go @@ -18,17 +18,11 @@ func (d *Daemon) trapSignals() { switch s { case syscall.SIGUSR1: d.handleSIGUSR1() - case syscall.SIGINT: + case syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT: d.Close() - os.Exit(int(syscall.SIGINT)) - case syscall.SIGTERM: - d.Close() - os.Exit(int(syscall.SIGTERM)) - case syscall.SIGABRT: - d.Close() - os.Exit(int(syscall.SIGABRT)) + os.Exit(int(s.(syscall.Signal))) default: - log.Warningf("unexpected signal %d", s) + log.Warningf("uncaught signal %d", s) } case <-d.ctx.Done(): return