handle handler maddrs

This commit is contained in:
Mantas Vidutis 2019-04-23 15:45:07 -07:00
parent e677c038ab
commit fea0b6f277
1 changed files with 24 additions and 11 deletions

View File

@ -148,17 +148,8 @@ func (d *Daemon) listen() {
}
}
func (d *Daemon) Close() error {
if err := d.host.Close(); err != nil {
return err
}
listenMaddr := d.listener.Multiaddr()
if err := d.listener.Close(); err != nil {
return err
}
for _, subMaddr := range ma.Split(listenMaddr) {
func clearUnixSockets(maddr ma.Multiaddr) error {
for _, subMaddr := range ma.Split(maddr) {
if subMaddr.Protocols()[0].Code == ma.P_UNIX {
socket, err := subMaddr.ValueForProtocol(ma.P_UNIX)
if err != nil {
@ -169,6 +160,28 @@ func (d *Daemon) Close() error {
}
}
}
return nil
}
func (d *Daemon) Close() error {
if err := d.host.Close(); err != nil {
return err
}
listenMaddr := 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 {
return err
}
return nil
}