Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Jun 21, 2023
1 parent 9563666 commit 2b2adde
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 20 additions & 0 deletions listen_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 0 additions & 20 deletions listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,26 +694,6 @@ func RegisterNetwork(network string, getListener ListenerFunc) {
networkTypes[network] = getListener
}

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()
}

type unixConn struct {
*net.UnixConn
filename string
Expand Down

0 comments on commit 2b2adde

Please sign in to comment.