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 {
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
}

View File

@ -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