plugin: drop explicit unlink
Go's `net` package [will unlink][1] for us, as long as we used Listen & friends to create the Unix socket. Go will even skip the unlink when the socket appears to be abstract (starts with a NUL, represented by an @), though we must be cautious to only create sockets with an abstract address on platforms that actually support it -- this caused [several][2] [bugs][3] before. [1]: https://pkg.go.dev/net#UnixListener.SetUnlinkOnClose [2]: https://github.com/docker/cli/pull/4783 [3]: https://github.com/docker/cli/pull/4863 Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
@ -2,19 +2,8 @@
|
||||
|
||||
package socket
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func listen(socketname string) (*net.UnixListener, error) {
|
||||
// Create an abstract socket -- this socket can be opened by name, but is
|
||||
// not present in the filesystem.
|
||||
return net.ListenUnix("unix", &net.UnixAddr{
|
||||
Name: "@" + socketname,
|
||||
Net: "unix",
|
||||
})
|
||||
}
|
||||
|
||||
func unlink(listener *net.UnixListener) {
|
||||
// Do nothing; the socket is not present in the filesystem.
|
||||
func socketName(basename string) string {
|
||||
// Address of an abstract socket -- this socket can be opened by name,
|
||||
// but is not present in the filesystem.
|
||||
return "@" + basename
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user