Make sure that UNIX sockets are removed before binding to them #496
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We run linux userspace click under the runit process supervisor. Sometimes click coredumps for one reason or another, and when restarting click we encounter errors about "address already in use", sometimes from the click control socket file, and sometimes from other unix socket files.
Socket and ControlSocket cleanup code will attempt to remove the
unix socket files they create. However, if click were to crash or
otherwise exit without calling cleanup, click will require an operator
to intervene and delete any unix socket resources not removed.
This change places an unlink() call before calls to bind() where
a unix socket is used. No error or logging is handled since it
is a best effort attempt to cleanup the unix socket.
I haven't done much evaluation on what the side effects might be, but I believe there aren't any? Feedback is appreciated, and I hope this helps.