summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2023-06-21 17:16:01 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2023-06-21 17:16:01 -0600
commit806341e089ed3e5ac825c4844f6fa4d437fdb642 (patch)
tree9c2d965a181f5386b52252d8640c5d826db0e86b
parent0468508e925597c4f9afd8fe235687d140c2fd59 (diff)
core: Properly preserve unix sockets (fix #5568)
-rw-r--r--listeners.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/listeners.go b/listeners.go
index 672bd83..1429b14 100644
--- a/listeners.go
+++ b/listeners.go
@@ -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)
}