@marcel91200 / caddy Mirror · read-only / commits / 9563666b
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 01:45 UTC

Fix compile on Windows, hopefully

Matthew Holt committed Jun 21, 2023 at 17:47 UTC 9563666bfb93f1708b044c7b1e5d0aa91afd029a
2 files changed +14 -13
listen_unix.go
+9
@@ -108,6 +108,15 @@ func listenTCPOrUnix(ctx context.Context, lnKey string, network, address string,
108 listenerPool.LoadOrStore(lnKey, nil)
109 }
110
111 + // if new listener is a unix socket, make sure we can reuse it later
112 + // (we do our own "unlink on close" -- not required, but more tidy)
113 + one := int32(1)
114 + if unix, ok := ln.(*net.UnixListener); ok {
115 + unix.SetUnlinkOnClose(false)
116 + ln = &unixListener{unix, lnKey, &one}
117 + unixSockets[lnKey] = ln.(*unixListener)
118 + }
119 +
120 // lightly wrap the listener so that when it is closed,
121 // we can decrement the usage pool counter
122 return deleteListener{ln, lnKey}, err
listeners.go
+5 -13
@@ -186,19 +186,11 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
186 return nil, fmt.Errorf("unsupported network type: %s", na.Network)
187 }
188
189 - // if new listener is a unix socket, make sure we can reuse it later
190 - // (we do our own "unlink on close" -- not required, but more tidy)
191 - one := int32(1)
192 - switch lnValue := ln.(type) {
193 - case deleteListener:
194 - if unix, ok := lnValue.Listener.(*net.UnixListener); ok {
195 - unix.SetUnlinkOnClose(false)
196 - ln = &unixListener{unix, lnKey, &one}
197 - unixSockets[lnKey] = ln.(*unixListener)
198 - }
199 - case *net.UnixConn:
200 - ln = &unixConn{lnValue, address, lnKey, &one}
201 - unixSockets[lnKey] = ln.(*unixConn)
189 + // TODO: Not 100% sure this is necessary, but we do this for net.UnixListener in listen_unix.go, so...
190 + if unix, ok := ln.(*net.UnixConn); ok {
191 + one := int32(1)
192 + ln = &unixConn{unix, address, lnKey, &one}
193 + unixSockets[lnKey] = unix
194 }
195
196 return ln, nil