-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
tests/servers.pm: pick unused port number with a server socket #11220
Conversation
This change replaces the previous method of picking a port number at random to try to start servers on, then retrying up to ten times with new random numbers each time, with a function that creates a server socket on port zero, thereby getting a suitable random port set by the kernel. That server socket is then closed and that port number is used to setup the actual test server on. There is a risk that *another* server can be started on the machine in the time gap, but the server verification feature will detect that.
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.
This should definitely help with reliable test server startup, especially in a free port starvation situation. If all the test servers actually start with this PR, then we can assume that they are all already setting SO_REUSEADDR and therefore need no further change to that effect.
Some points that I noticed while reviewing:
- $serverstartretries can be deleted
- %usedports can be deleted
The first return value must be nonzero to mean error. e.g. 0+!$http2pid is 0 on
success (when $http2pid contains a PID) and 1 on error (when $http2pid is
zero). That's going to cause startservers() the return the wrong value on error.
I had to refactor startservers() in f82a38e to return a fine-grained error
in order to preserve the right behaviour after other refactoring.
|
This change replaces the previous method of picking a port number at random to try to start servers on, then retrying up to ten times with new random numbers each time, with a function that creates a server socket on port zero, thereby getting a suitable random port set by the kernel. That server socket is then closed and that port number is used to setup the actual test server on. There is a risk that *another* server can be started on the machine in the time gap, but the server verification feature will detect that. Closes curl#11220
This change replaces the previous method of picking a port number at random to try to start servers on, then retrying up to ten times with new random numbers each time, with a function that creates a server socket on port zero, thereby getting a suitable random port set by the kernel. That server socket is then closed and that port number is used to setup the actual test server on. There is a risk that *another* server can be started on the machine in the time gap, but the server verification feature will detect that. Closes curl#11220
This change replaces the previous method of picking a port number at random to try to start servers on, then retrying up to ten times with new random numbers each time, with a function that creates a server socket on port zero, thereby getting a suitable random port set by the kernel. That server socket is then closed and that port number is used to setup the actual test server on.
There is a risk that another server can be started on the machine in the time gap, but the server verification feature will detect that.