-
Notifications
You must be signed in to change notification settings - Fork 853
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
Fixed bug: initial state of an epoll eid for listener socket not set #2444
Open
ethouris
wants to merge
21
commits into
Haivision:master
Choose a base branch
from
ethouris:dev-epoll-listener-init
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ges by google test
… dead code (this solution deadlocks)
ethouris
added
Type: Bug
Indicates an unexpected problem or unintended behavior
[core]
Area: Changes in SRT library core
labels
Oct 11, 2023
…ny pending connection can accept a group. Removed other pending sockets after accepting a group. Fixed tests to handle options also with RAII srt initializer
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2444 +/- ##
==========================================
+ Coverage 65.08% 67.83% +2.75%
==========================================
Files 101 101
Lines 17655 18229 +574
==========================================
+ Hits 11490 12365 +875
+ Misses 6165 5864 -301 ☔ View full report in Codecov by Sentry. |
This was referenced Sep 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem 1: if you make a listener socket, but delay with subscribing it to the epoll eid, and the first incoming connection happens before this subscription, the listener's readiness for accept will not be seen in the EID. Generally, it's the epoll flag updating problem.
Problem 2: Incorrectly handled the case of accepting the group connection as the first accepted in various corner cases concerning the multiple pending connections: the idea was wrong to simply qualify the first pending connection as the only one that should make the application get the group connection. This is only working with the optimistic precondition that this connection will not break in the meantime before being accepted.
Changes applied here:
addEPoll
for a socket there's an additional check for events done for a case when it's a listener socket. TheSRT_EPOLL_IN
event is set only if there are any queued sockets, and if they are group members, it's also checked if the group isn't already connected and accept-extractedm_bPending
flag in the group structure. This is true by default for a group created as a mirror group on the listener side for the very first member connection. The group stops being pending only at the moment when it was extracted through thesrt_accept
call.SRT_EPOLL_IN
flag set (even though only one of them can provide the group connection throughsrt_accept
).srt_accept
has been updated and all these above rules described.Several changed rules are:
Previously: when there were multiple incoming connections for the same group, especially coming in over different listener sockets, only the first ever reporting in the group was set the
SRT_EPOLL_IN
flag and only from that one it was possible to accept the group connection, others were always handled in the background. Also theSRT_EPOLL_UPDATE
flag was not set properly if the subscription for the listener socket was done after the connection pending state.Now: when there are multiple incoming connections for the same group, all listeners are set
SRT_EPOLL_IN
flag and the application can accept the group off any listener that reports incoming connection. Once the group is extracted through callingsrt_accept
on any of the listeners, all pending connections for the same group in any other listeners are withdrawn, handled in the background, andSRT_EPOLL_IN
flag is cleared if there are no more pending connections.The reasoning: theoretically it doesn't matter from which listener socket you will accept the group, so whether it was only one, or all of them, it shouldn't matter. But the problem could be if this first connection gets broken before the application does accept, while other connections from the same group are still pending. In such a situation the old solution could be in a weird kind of state with some kind of "forever connection" seen at the caller side, but never accepted at the listener side.