Skip to content

Commit

Permalink
core: Properly preserve unix sockets (fix #5568)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Jun 21, 2023
1 parent 0468508 commit 806341e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 806341e

Please sign in to comment.