Skip to content

Commit

Permalink
[core] Refact: moved code to processCtrlShutdown
Browse files Browse the repository at this point in the history
dedicated function
  • Loading branch information
maxsharabayko committed Apr 9, 2021
1 parent eb6e029 commit efd0c0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
23 changes: 14 additions & 9 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8399,6 +8399,19 @@ void CUDT::processCtrlDropReq(const CPacket& ctrlpkt)
}
}

void CUDT::processCtrlShutdown(const CPacket& ctrlpkt)
{
m_bShutdown = true;
m_bClosing = true;
m_bBroken = true;
m_iBrokenCounter = 60;

// This does the same as it would happen on connection timeout,
// just we know about this state prematurely thanks to this message.
updateBrokenConnection();
completeBrokenConnectionDependencies(SRT_ECONNLOST); // LOCKS!
}

void CUDT::processCtrl(const CPacket &ctrlpkt)
{
// Just heard from the peer, reset the expiration count.
Expand Down Expand Up @@ -8443,15 +8456,7 @@ void CUDT::processCtrl(const CPacket &ctrlpkt)
break;

case UMSG_SHUTDOWN: // 101 - Shutdown
m_bShutdown = true;
m_bClosing = true;
m_bBroken = true;
m_iBrokenCounter = 60;

// This does the same as it would happen on connection timeout,
// just we know about this state prematurely thanks to this message.
updateBrokenConnection();
completeBrokenConnectionDependencies(SRT_ECONNLOST); // LOCKS!
processCtrlShutdown(ctrlpkt);
break;

case UMSG_DROPREQ: // 111 - Msg drop request
Expand Down
4 changes: 4 additions & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,10 @@ class CUDT
/// @param ctrlpkt incoming drop request packet
void processCtrlDropReq(const CPacket& ctrlpkt);

/// @brief Process incoming shutdown control packet
/// @param ctrlpkt incoming shutdown packet
void processCtrlShutdown(const CPacket& ctrlpkt);

/// @brief Update sender's loss list on an incoming acknowledgement.
/// @param ackdata_seqno sequence number of a data packet being acknowledged
void updateSndLossListOnACK(int32_t ackdata_seqno);
Expand Down

0 comments on commit efd0c0b

Please sign in to comment.