Skip to content

Commit

Permalink
[core] Refax: safety improvements for RCV loss list and closing state (
Browse files Browse the repository at this point in the history
  • Loading branch information
ethouris authored Nov 8, 2022
1 parent 491e6e8 commit 71c3e40
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ class CUDTSocket
/// to finish sending the data that were scheduled for sending so far.
void setClosed();

// This is necessary to be called from the group before the group clears
// the connection with the socket. As for managed groups (and there are
// currently no other group types), a socket disconnected from the group
// is no longer usable.
void setClosing()
{
core().m_bClosing = true;
}

/// This does the same as setClosed, plus sets the m_bBroken to true.
/// Such a socket can still be read from so that remaining data from
/// the receiver buffer can be read, but no longer sends anything.
Expand Down
3 changes: 3 additions & 0 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11089,7 +11089,10 @@ int srt::CUDT::checkNAKTimer(const steady_clock::time_point& currtime)
* not knowing what to retransmit when the only NAK sent by receiver is lost,
* all packets past last ACK are retransmitted (rexmitMethod() == SRM_FASTREXMIT).
*/
enterCS(m_RcvLossLock);
const int loss_len = m_pRcvLossList->getLossLength();
leaveCS(m_RcvLossLock);

SRT_ASSERT(loss_len >= 0);
int debug_decision = BECAUSE_NO_REASON;

Expand Down
10 changes: 10 additions & 0 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,16 @@ void CUDTGroup::close()
HLOGC(smlog.Debug, log << "group/close: IPE(NF): group member @" << ig->id << " already deleted");
continue;
}

// Make the socket closing BEFORE withdrawing its group membership
// because a socket created as a group member cannot be valid
// without the group.
// This is not true in case of non-managed groups, which
// only collect sockets, but also non-managed groups should not
// use common group buffering and tsbpd. Also currently there are
// no other groups than managed one.
s->setClosing();

s->m_GroupOf = NULL;
s->m_GroupMemberData = NULL;
HLOGC(smlog.Debug, log << "group/close: CUTTING OFF @" << ig->id << " (found as @" << s->m_SocketID << ") from the group");
Expand Down

0 comments on commit 71c3e40

Please sign in to comment.