summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--listen_unix.go20
-rw-r--r--listeners.go20
2 files changed, 20 insertions, 20 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.
diff --git a/listeners.go b/listeners.go
index 08bdbcf..1387d38 100644
--- a/listeners.go
+++ b/listeners.go
@@ -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