Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Unix domain sockets for RPC #314

Closed
ncreep opened this issue Oct 8, 2015 · 2 comments
Closed

Using Unix domain sockets for RPC #314

ncreep opened this issue Oct 8, 2015 · 2 comments

Comments

@ncreep
Copy link
Contributor

ncreep commented Oct 8, 2015

In the Windows support issue it was suggested to use Unix domain sockets where available. I tried to tackle this issue, here are some observations.

With plain sockets we don't need to select a port, one is chosen randomly every time. Ideally something similar should happen when using Unix sockets. There is an autobinding feature that can achieve this, but it seems to be supported only on Linux, and my rudimentary attempts of getting it to work in the code failed (but that's probably fixable).

Generally (and portably), Unix sockets use file names for communication. As an alternative to random ports, I tried creating a temporary file, this has the following complications:

  • A socket cannot be bound to an existing file, so the temporary file must be deleted before it's used for communication. This might introduce, probably rare, race conditions.
  • The file remains in the filesystem after the sockets are closed. This shouldn't be a real problem, since the file is either created in the system's temp directory or in the current session's directory.

I've implemented the above, and it seems to be working. But I would prefer to use some more reliable way of generating file names.

Any suggestions?

@ncreep
Copy link
Contributor Author

ncreep commented Oct 10, 2015

Thinking about it, it is possible to generate a random directory for each socket, and then create the communication file there (again, noting that some of those will remain in the user's temporary directory). That should avoid the race condition mentioned above.

If that sounds reasonable, I can implement it and send a pull request.

@mgsloan
Copy link
Contributor

mgsloan commented Oct 12, 2015

Sure, that sounds reasonable to me! Feel free to implement this.

@ncreep ncreep mentioned this issue Oct 12, 2015
@ncreep ncreep closed this as completed Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants