mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
Fix compile on Windows, hopefully
This commit is contained in:
parent
806341e089
commit
9563666bfb
2 changed files with 14 additions and 13 deletions
|
@ -108,6 +108,15 @@ func listenTCPOrUnix(ctx context.Context, lnKey string, network, address string,
|
||||||
listenerPool.LoadOrStore(lnKey, nil)
|
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,
|
// lightly wrap the listener so that when it is closed,
|
||||||
// we can decrement the usage pool counter
|
// we can decrement the usage pool counter
|
||||||
return deleteListener{ln, lnKey}, err
|
return deleteListener{ln, lnKey}, err
|
||||||
|
|
16
listeners.go
16
listeners.go
|
@ -186,19 +186,11 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
|
||||||
return nil, fmt.Errorf("unsupported network type: %s", na.Network)
|
return nil, fmt.Errorf("unsupported network type: %s", na.Network)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if new listener is a unix socket, make sure we can reuse it later
|
// TODO: Not 100% sure this is necessary, but we do this for net.UnixListener in listen_unix.go, so...
|
||||||
// (we do our own "unlink on close" -- not required, but more tidy)
|
if unix, ok := ln.(*net.UnixConn); ok {
|
||||||
one := int32(1)
|
one := int32(1)
|
||||||
switch lnValue := ln.(type) {
|
ln = &unixConn{unix, address, lnKey, &one}
|
||||||
case deleteListener:
|
unixSockets[lnKey] = unix
|
||||||
if unix, ok := lnValue.Listener.(*net.UnixListener); ok {
|
|
||||||
unix.SetUnlinkOnClose(false)
|
|
||||||
ln = &unixListener{unix, lnKey, &one}
|
|
||||||
unixSockets[lnKey] = ln.(*unixListener)
|
|
||||||
}
|
|
||||||
case *net.UnixConn:
|
|
||||||
ln = &unixConn{lnValue, address, lnKey, &one}
|
|
||||||
unixSockets[lnKey] = ln.(*unixConn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ln, nil
|
return ln, nil
|
||||||
|
|
Loading…
Reference in a new issue