-
Notifications
You must be signed in to change notification settings - Fork 851
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
[core] Fixed: closing socket should mark and signal so that srt_connect call can exit immediately #2032
base: master
Are you sure you want to change the base?
Conversation
…ct call can exit immediately
Weird...
|
Not weird. The problem is bigger than I thought. I found a solution, but it's a dirty workaround, you might not like it. |
…fore changing the flag. Otherwise it would confuse the closing function when used on a connected socket
Indeed not sure about this fix. It looks like if Furthermore, the fix might make even more fragile:
At the same time, I don't see an easy way to fix issue #2029 without intense refactoring. Unlocking |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2032 +/- ##
==========================================
+ Coverage 64.88% 67.14% +2.26%
==========================================
Files 101 103 +2
Lines 17634 20486 +2852
==========================================
+ Hits 11441 13756 +2315
- Misses 6193 6730 +537 ☔ View full report in Codecov by Sentry. |
Ok, I think I know why the tests on Travis fail. The socket gets closed, but somehow the binding wasn't freed, which is exactly the problem to solve here. So the problem isn't solved. |
Ok, it looks like all tests pass now. Out of these two new tests, RapidClose passes even with this fix blocked, but RendezvousHangs is failing. Likely all most important fixes were moved elsewhere, and this one just kicks off the spare buffer CV to prevent it from blocking the closing action. |
Fixes #2029
Note that some parts of it have been earlier exported to other PRs, so this one fixes only one remaining problem:
The
srt_connect
call makes a runaround loop with sending packets and attempting to read packets from the socket (throughCRcvQueue::recvfrom
) in a hope that it will connect at last. The problem is that for the whole time of running this loop it locksCSocket::m_ControlLock
andCUDT::m_ConnectionLock
(in this order), which holds the call tosrt_close()
from execution until this loop exits, and the loop exits only on timeout. The reading from the queue causes reading from socket with 1s maximum waiting time after which the conditions are being rechecked.Fix:
CRcvQueue::recvfrom
before the 1s timeout.m_bClosing
ANDm_bBroken
flags are checked after reading byCRcvQueue::recvfrom
so that the loop can interrupt immediately.srt_close
call sets them_bClosing
flag and "kicks" the condition forCRcvQueue::recvfrom
. This finally leads to immediate exit of the loop, so thatsrt_close()
can continue.