Join GitHub today
GitHub is home to over 40 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
I thought that we avoided creating on-disk Unix sockets, but I was mistaken. Use one to test CL 17458. Fixes #11826. Change-Id: Iaa1fb007b95fa6be48200586522a6d4789ecd346 Reviewed-on: https://go-review.googlesource.com/17725 Run-TryBot: Brad Fitzpatrick <firstname.lastname@example.org> Reviewed-by: Ian Lance Taylor <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org>