Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net: UnixListener unlinks socket files inherited via socket activation #11826
docker can use systemd for socket activation. docker creates a net.UnixListener using net.FileListener on the inherited fd. naturally, upon shutdown, docker calls Close on the net.Listener.
in unixsock_posix.go, Close calls syscall.Unlink on the file name that was found via getsockname. this code has been there since at least 2011.
the result of this is that upon the socket-activated service (docker) restarting, the service will reconnect to the inherited file descriptor, but clients of that socket will no longer be able to reach it because the socket file in the filesystem is gone, and never recreated.
this seems to have been worked around in docker in moby/moby@053c355, but this affects any socket-activated go program that 'properly' Closes it's UnixListeners.
if the UnixListener was not responsible for creating the socket file, it should not unlink the socket file on Close.
This can be triggered without docker, systemd, etc by e.g. passing an FD of a listening unix domain socket to multiple children, each child using