review updates

This commit is contained in:
Mantas Vidutis 2019-04-24 07:21:02 -07:00
parent b629040242
commit 2307f5006a
2 changed files with 7 additions and 19 deletions

View File

@ -148,8 +148,8 @@ func (d *Daemon) listen() {
} }
} }
func clearUnixSockets(maddr ma.Multiaddr) error { func clearUnixSockets(path ma.Multiaddr) error {
for _, subMaddr := range ma.Split(maddr) { for _, subMaddr := range ma.Split(path) {
if subMaddr.Protocols()[0].Code == ma.P_UNIX { if subMaddr.Protocols()[0].Code == ma.P_UNIX {
socket, err := subMaddr.ValueForProtocol(ma.P_UNIX) socket, err := subMaddr.ValueForProtocol(ma.P_UNIX)
if err != nil { if err != nil {
@ -168,18 +168,12 @@ func (d *Daemon) Close() error {
return err return err
} }
listenMaddr := d.listener.Multiaddr() listenAddr := d.listener.Multiaddr()
if err := d.listener.Close(); err != nil { if err := d.listener.Close(); err != nil {
return err return err
} }
for _, maddr := range d.handlers { if err := clearUnixSockets(listenAddr); err != nil {
if err := clearUnixSockets(maddr); err != nil {
return err
}
}
if err := clearUnixSockets(listenMaddr); err != nil {
return err return err
} }

View File

@ -18,17 +18,11 @@ func (d *Daemon) trapSignals() {
switch s { switch s {
case syscall.SIGUSR1: case syscall.SIGUSR1:
d.handleSIGUSR1() d.handleSIGUSR1()
case syscall.SIGINT: case syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT:
d.Close() d.Close()
os.Exit(int(syscall.SIGINT)) os.Exit(int(s.(syscall.Signal)))
case syscall.SIGTERM:
d.Close()
os.Exit(int(syscall.SIGTERM))
case syscall.SIGABRT:
d.Close()
os.Exit(int(syscall.SIGABRT))
default: default:
log.Warningf("unexpected signal %d", s) log.Warningf("uncaught signal %d", s)
} }
case <-d.ctx.Done(): case <-d.ctx.Done():
return return