-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement issue #6296 passing FDs / socket activation #6573
base: master
Are you sure you want to change the base?
Conversation
listen.go
Outdated
func() { | ||
socketFilesMu.Lock() | ||
defer socketFilesMu.Unlock() | ||
|
||
socketFdWide := uintptr(fd) | ||
var ok bool | ||
|
||
socketFile, ok = socketFiles[socketFdWide] | ||
|
||
if !ok { | ||
socketFile = os.NewFile(socketFdWide, lnKey) | ||
socketFiles[socketFdWide] = socketFile | ||
} | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only significantly changed behavior from #6543 ; listenReusable
locks the fd number -> file map. this is similar to what reuseUnixSocket
does with unixSockets
, but there are no messy race conditions involving unlink or the filesystem. it just needs to ensure that every fd is opened at most once, so the lock prevents multiple reads before the first write.
listen_unix.go
Outdated
func() { | ||
socketFilesMu.Lock() | ||
defer socketFilesMu.Unlock() | ||
|
||
socketFdWide := uintptr(socketFd) | ||
var ok bool | ||
|
||
socketFile, ok = socketFiles[socketFdWide] | ||
|
||
if !ok { | ||
socketFile = os.NewFile(socketFdWide, lnKey) | ||
socketFiles[socketFdWide] = socketFile | ||
} | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
third time's the charm ☘️
example Caddyfile:
as seen above, two reserved networks
fd
andfdgram
have been added.fd/3
creates a FileListener from fd 3,fdgram/4
creates a FilePacketConn from fd 4. this simplifies configuration compared to #6543 , but the "actual" host addresses are no longer visible. so, for health checks and the admin interface, fds are treated similarly to unix sockets.this is a good thing i think, fds should be decoupled from the address they are bound to. separate config options can be added to override the origin address for health checks / the admin interface if needed.
link to issue: #6296