From 9563666bfb93f1708b044c7b1e5d0aa91afd029a Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 21 Jun 2023 17:47:23 -0600 Subject: Fix compile on Windows, hopefully --- listen_unix.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'listen_unix.go') diff --git a/listen_unix.go b/listen_unix.go index 7011a1e..e31ecac 100644 --- a/listen_unix.go +++ b/listen_unix.go @@ -108,6 +108,15 @@ func listenTCPOrUnix(ctx context.Context, lnKey string, network, address string, listenerPool.LoadOrStore(lnKey, nil) } + // 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) + if unix, ok := ln.(*net.UnixListener); ok { + unix.SetUnlinkOnClose(false) + ln = &unixListener{unix, lnKey, &one} + unixSockets[lnKey] = ln.(*unixListener) + } + // lightly wrap the listener so that when it is closed, // we can decrement the usage pool counter return deleteListener{ln, lnKey}, err -- cgit v1.2.3