core: Properly preserve unix sockets (fix #5568)

This commit is contained in:
Matthew Holt 2023-06-21 17:16:01 -06:00
parent 0468508e92
commit 806341e089
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -189,13 +189,15 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
// if new listener is a unix socket, make sure we can reuse it later
// (we do our own "unlink on close" -- not required, but more tidy)
one := int32(1)
switch unix := ln.(type) {
case *net.UnixListener:
unix.SetUnlinkOnClose(false)
ln = &unixListener{unix, lnKey, &one}
unixSockets[lnKey] = ln.(*unixListener)
switch lnValue := ln.(type) {
case deleteListener:
if unix, ok := lnValue.Listener.(*net.UnixListener); ok {
unix.SetUnlinkOnClose(false)
ln = &unixListener{unix, lnKey, &one}
unixSockets[lnKey] = ln.(*unixListener)
}
case *net.UnixConn:
ln = &unixConn{unix, address, lnKey, &one}
ln = &unixConn{lnValue, address, lnKey, &one}
unixSockets[lnKey] = ln.(*unixConn)
}