-
Notifications
You must be signed in to change notification settings - Fork 63
Ensure lo_server_recv keeps looping until valid message is dispatched #174
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
Conversation
…github actions if test fails.
…his clear revents for next socket instead.
| return dispatch_queued(s, 0); | ||
| while (1) { | ||
| while ((ret = lo_servers_wait_internal(&s, &recvd, &queued, 1, 100)) == 0) {} | ||
| if (ret > 0) { |
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.
Okay I'm really happy with this patch in the sense that I didn't expect it would be so simple. But it does feel scary introducing a while (1) here, no exit plan at all in case of problems. (Although admittedly the existing inner while is arguably just as scary.)
However, I think what's happened here is that lo_server_recv is simply the oldest "recv" function and doesn't have the same semantics in the return values as lo_server_wait for instance, where its docs indicate that it may return "-1 if there is an error that causes the function to return early". Unfortunately lo_server_recv has no such error code.
(Also according to docs, the combination of lo_server_wait and lo_server_recv is supposed to guarantee reception of a single message, so I guess this was the "out" I tried to design in post-hoc regarding this situation.)
But, here we see that ret can have the value -1 due to lo_servers_wait_internal. And there is the question if we should really keep looping on poll if poll returned an error, which is what makes it return that.
So before accepting this change, I want to just consider here whether there is any danger of backwards-incompatible breakage if we exit this while if ret == -1 (or ret < 0) Then, do we return the -1 from lo_server_recv and add it to the docs, or do we return 0, which would be closer to the current behaviour?
Co-authored-by: Stephen Sinclair <radarsat1@users.noreply.github.com>
|
Github seems to have deleted my comment :( In brief it suggested:
We still need to deal with an edge case if |
This PR includes 2 fixes:
lo_server_del_socket()is called the socket indexinow refers to the next socket (if it exists). Socket memory is not reallocated here so no memory-access error occured.lo_server_recv()to return early, even though no message had been dispatched. This PR ensured thatlo_server_recv()keeps looping in this case.