-
Notifications
You must be signed in to change notification settings - Fork 866
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
[FR] Allow a callback set by srt_listen_callback to be removed #2634
Comments
There could be quite a problem with having the listener callback removed without making sure first that the previously set listener callback isn't currently being executed. I can hardly imagine any logics standing behind a procedure when your socket is open for any incoming connection, about which you have no idea when they would happen, and after having 5 new connections coming in you let in 2 with the execution of the listener callback and then the last 3 without. Note that usually - although this somehow wasn't exactly intended (maybe this check should be added) - you install the listener callback before setting up the listening state by So if you really need by some reason to continue listening on the given port, but stop using the listener callback on that bindpoint, you can currently do it by creating a new listener socket and close the old one. This means that some connections that are pending at this very moment, these will be rejected, but once the operation is done, all further connections will be accepted, and processed without the listener callback previously installed. Note the order though:
For me it sounds more reasonable though that the time gap between closing the old listener and setting listen on the new one should be even intentionally extended, not minimized. But as I said, I don't exactly understand the logics of the application that might want to do such a thing. |
Fair enough, I suspected it would be more complicated underneath. There may be an inconsistency - given that I'm also curious about a point you made. I am currently setting the callback before calling |
This is the correct order and exactly the order I described - though I can see now that the listener callback function lacks some API guards and more than I saw above. Thanks for pointing me this. Note that the listener "starts working" exactly at the moment after you call |
The inconsistency is resolved in #2683; closing this one. Please reopen if this doesn't match the conditions. |
There may be cases where the "opaque" user-pointer value that is passed to
srt_listen_callback
is associated with some resources.If an RAII style approach is being taken then ideally there is a symmetry to the set up. So the callback would be removed as a reverse operation to the addition.
However, when calling
srt_listen_callback
with anullptr
for the callback function the call is rejected as unsupported.This appears to suggest that (once set) the callback has to exist as long as the socket. It puts the emphasis on the client to manage the state in the callback, as opposed to just switching it off.
Could the
srt_listen_callback
support reset vianullptr
?Presumably some internal state/thread synchronisation management may be the reason this is not currently available?
The text was updated successfully, but these errors were encountered: