-
-
Notifications
You must be signed in to change notification settings - Fork 22
Fix getting a free socket on macos #420
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
base: master
Are you sure you want to change the base?
Conversation
@bell-db fyi |
* which does not conflict with existing 'localhost' sockets, | ||
* resulting in a conflict later on in MacPluginFrontend | ||
*/ | ||
def getFreeSocket(): ServerSocket = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to do this on all platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason is me not being able to test it on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a CI job that will test it on Windows, Mac and Linux. Can you also run scalafmt so the tests will pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I've updated the pull request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thesamet, could you approve the awaiting workflow?
Here is a new fix for a free socket on mac problem, without restry.
Turns out mac allows a socket on ANY host (. in netstat) to bind even though a socket with localhost and a same port is present in LISTENING state. This is different from linux, where such an attempt would fail with a java.net.BindException.
A way to fix this is by simply passing a localhost (or rather 127.0.0.1, to match MacPluginFrontend) to ServerSocket constructor.
I've test it on my project, and got no failures on 5 rebuilds (it used to be 2 failed bazel targets per rebuild on protoc-bridge:0.9.8).