Skip to content

Commit

Permalink
[core] Check if socket is still open before replying to HS
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Aug 12, 2021
1 parent 252337c commit d7dcf0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3769,6 +3769,8 @@ bool srt::CUDT::processAsyncConnectRequest(EReadStatus rst,
bool status = true;

ScopedLock cg(m_ConnectionLock);
if (!m_bOpened) // Check the socket has not been closed before already.
return false;

if (cst == CONN_RENDEZVOUS)
{
Expand Down
11 changes: 6 additions & 5 deletions srtcore/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,11 +989,12 @@ void srt::CRendezvousQueue::updateConnStatus(EReadStatus rst, EConnectStatus cst
for (vector<LinkStatusInfo>::iterator i = toRemove.begin(); i != toRemove.end(); ++i)
{
HLOGC(cnlog.Debug, log << "updateConnStatus: COMPLETING dep objects update on failed @" << i->id);
/*
* Setting m_bConnecting to false but keeping socket in rendezvous queue is not a good idea.
* Next CUDT::close will not remove it from rendezvous queue (because !m_bConnecting)
* and may crash on next pass.
*/
//
// Setting m_bConnecting to false, and need to remove the socket from the rendezvous queue
// because the next CUDT::close will not remove it from the queue when m_bConnecting = false,
// and may crash on next pass.
//
// TODO: maybe lock i->u->m_ConnectionLock?
i->u->m_bConnecting = false;
remove(i->u->m_SocketID);

Expand Down

0 comments on commit d7dcf0c

Please sign in to comment.