diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2023-06-21 17:59:54 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2023-06-21 17:59:54 -0600 |
commit | 2b2addebb8cc5dfc7d4d1d34c82f3c46159fea12 (patch) | |
tree | c59228edb42936d4127f1e119bd5341da0171fab /listen_unix.go | |
parent | 9563666bfb93f1708b044c7b1e5d0aa91afd029a (diff) |
Appease linter
Diffstat (limited to 'listen_unix.go')
-rw-r--r-- | listen_unix.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/listen_unix.go b/listen_unix.go index e31ecac..8870da5 100644 --- a/listen_unix.go +++ b/listen_unix.go @@ -138,6 +138,26 @@ func reusePort(network, address string, conn syscall.RawConn) error { }) } +type unixListener struct { + *net.UnixListener + mapKey string + count *int32 // accessed atomically +} + +func (uln *unixListener) Close() error { + newCount := atomic.AddInt32(uln.count, -1) + if newCount == 0 { + defer func() { + addr := uln.Addr().String() + unixSocketsMu.Lock() + delete(unixSockets, uln.mapKey) + unixSocketsMu.Unlock() + _ = syscall.Unlink(addr) + }() + } + return uln.UnixListener.Close() +} + // deleteListener is a type that simply deletes itself // from the listenerPool when it closes. It is used // solely for the purpose of reference counting (i.e. |