Cleanup socket file
This commit is contained in:
parent
355e9bd619
commit
2dfd4e7d8c
|
@ -57,7 +57,7 @@ func (l *UAPIListener) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UAPIListener) Addr() net.Addr {
|
func (l *UAPIListener) Addr() net.Addr {
|
||||||
return nil
|
return l.listener.Addr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func UAPIListen(name string, file *os.File) (net.Listener, error) {
|
func UAPIListen(name string, file *os.File) (net.Listener, error) {
|
||||||
|
@ -75,6 +75,10 @@ func UAPIListen(name string, file *os.File) (net.Listener, error) {
|
||||||
connErr: make(chan error, 1),
|
connErr: make(chan error, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if unixListener, ok := listener.(*net.UnixListener); ok {
|
||||||
|
unixListener.SetUnlinkOnClose(true)
|
||||||
|
}
|
||||||
|
|
||||||
socketPath := path.Join(
|
socketPath := path.Join(
|
||||||
socketDirectory,
|
socketDirectory,
|
||||||
fmt.Sprintf(socketName, name),
|
fmt.Sprintf(socketName, name),
|
||||||
|
|
|
@ -46,8 +46,8 @@ func (l *UAPIListener) Accept() (net.Conn, error) {
|
||||||
|
|
||||||
func (l *UAPIListener) Close() error {
|
func (l *UAPIListener) Close() error {
|
||||||
err1 := unix.Close(l.inotifyFd)
|
err1 := unix.Close(l.inotifyFd)
|
||||||
err2 := l.listener.Close()
|
err2 := l.inotifyRWCancel.Cancel()
|
||||||
err3 := l.inotifyRWCancel.Cancel()
|
err3 := l.listener.Close()
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
return err1
|
return err1
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func (l *UAPIListener) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UAPIListener) Addr() net.Addr {
|
func (l *UAPIListener) Addr() net.Addr {
|
||||||
return nil
|
return l.listener.Addr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func UAPIListen(name string, file *os.File) (net.Listener, error) {
|
func UAPIListen(name string, file *os.File) (net.Listener, error) {
|
||||||
|
@ -70,6 +70,10 @@ func UAPIListen(name string, file *os.File) (net.Listener, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if unixListener, ok := listener.(*net.UnixListener); ok {
|
||||||
|
unixListener.SetUnlinkOnClose(true)
|
||||||
|
}
|
||||||
|
|
||||||
uapi := &UAPIListener{
|
uapi := &UAPIListener{
|
||||||
listener: listener,
|
listener: listener,
|
||||||
connNew: make(chan net.Conn, 1),
|
connNew: make(chan net.Conn, 1),
|
||||||
|
|
Loading…
Reference in a new issue