Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

unlink stale unix socket before binding #425

Closed
socketpair opened this issue Sep 22, 2016 · 6 comments
Closed

unlink stale unix socket before binding #425

socketpair opened this issue Sep 22, 2016 · 6 comments

Comments

@socketpair
Copy link

loop.create_unix_server() should remove socket at that path if it exists. Every application that wants to use unix socket server should do that. Why not to add code that removes unix socket before binding ?

It should:

  1. Check if it is exists and that is UNIX socket (i.e. do os.stat())
  2. raise exception if removal failed, raise exception if this path exists but is not unix socket.
  3. not even try to remove if path starts with zero byte (i.e. abstract unix socket)
@gjcarneiro
Copy link

What if you are trying, by mistake, to start a second instance of a server, with the previous one still running? We want to catch that mistake, instead of silently removing the existing socket.

@socketpair
Copy link
Author

All software that I see unlinks stale socket unconditionally. Can you show any one that checks for the other instance ? Also, seems the kernel checks if address already in use during bind() even when FS node is removed.

@1st1
Copy link
Member

1st1 commented Oct 5, 2016

+1 one to do this. @socketpair can you quickly make a PR (so that we can fix this before 3.6b2)?

@1st1
Copy link
Member

1st1 commented Oct 5, 2016

Although there is another approach: maybe the correct thing to do is to remove the socket file after we close the unix server? How Twisted/Tornado implement this?

@socketpair
Copy link
Author

@1st1 @ZhukovAlexander @gjcarneiro please review

@1st1 1st1 closed this as completed in 806cc68 Oct 9, 2016
fafhrd91 pushed a commit to aio-libs/aiohttp that referenced this issue Feb 23, 2017
…ttempting bind.

This is in case the event loop implementation does not already do this.
See python/asyncio#425.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants