-
Notifications
You must be signed in to change notification settings - Fork 195
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
Two issues with Socket.wait() #6
Comments
No problem. I'm on vacation this week but will try to find some time to take a look. Thanks. |
billabt
pushed a commit
that referenced
this issue
Jul 6, 2016
…ait based on a passed timer value, an immediate return (i.e. quick check) and an indefinite wait.
In order to not lose existing functionality to allow a quick check (i.e. check and return immediately), I've modified the API so that we can do both, the quick check plus the indefinite wait.
|
Looks great, thanks! -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
I've been doing some work on the Kitura project and in sketching out some ideas for performance optimizations I've found what I think are a couple of issues / improvements to be made to Socket.wait():
First:
In the wait() function a time is initialized:
Some code following this computes a time based on the timeout UInt that gets passed to wait() in the event that timeout is greater than 0.
If, however, you pass 0 as a timeout (to NOT use a timeout at all and just select() forever), the result is that select() instantly returns as the timer fires immediately.
So I would suggest modifying this line:
With some code that passes nil in place of &timer in the event that a 0 timeout is passed to the wait() function.
Secondly:
At the start of wait() the sockets in the socket group are looped and any socket with an invalid descriptor causes an exception to throw. All good.
The problem is that each socket is also checked for "isConnected" and any sockets where isConnected = false also throw an exception.
This basically means you can't use wait() to monitor sockets that are both signalling that data is ready to be read AS WELL as listen() sockets waiting for connections (which are technically not connected).
So, I'd suggest changing this one piece of code:
To:
This would allow listen() sockets to be bundled in to the select(). Most helpful!
I'd open a PR but I'm knee deep in toolchain 2016-06-05 right now and I see BlueSocket is already tagged ahead to a 2016-06-20 dependency.
The text was updated successfully, but these errors were encountered: