Skip to content
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

Main/backup: changing switching rules #1857

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ void CUDT::construct()
m_bClosing = false;
m_bShutdown = false;
m_bBroken = false;
m_bBreakAsUnstable = false;
// TODO: m_iBrokenCounter should be still set to some default.
m_bPeerHealth = true;
m_RejectReason = SRT_REJ_UNKNOWN;
Expand Down Expand Up @@ -950,12 +951,13 @@ void CUDT::open()
m_tsLastRspAckTime = currtime;
m_tsLastSndTime = currtime;

m_iReXmitCount = 1;
m_tsUnstableSince = steady_clock::time_point();
m_tsUnstableSince = steady_clock::time_point();
m_tsFreshActivation = steady_clock::time_point();
m_tsWarySince = steady_clock::time_point();

m_iReXmitCount = 1;
m_iPktCount = 0;
m_iLightACKCount = 1;

m_tsNextSendTime = steady_clock::time_point();
m_tdSendTimeDiff = microseconds_from(0);

Expand Down Expand Up @@ -10778,15 +10780,15 @@ bool CUDT::checkExpTimer(const steady_clock::time_point& currtime, int check_rea
next_exp_time = m_tsLastRspTime + exp_timeout;
}

if (currtime <= next_exp_time)
if (currtime <= next_exp_time && !m_bBreakAsUnstable)
return false;

// ms -> us
const int PEER_IDLE_TMO_US = m_config.iPeerIdleTimeout * 1000;
// Haven't received any information from the peer, is it dead?!
// timeout: at least 16 expirations and must be greater than 5 seconds
if ((m_iEXPCount > COMM_RESPONSE_MAX_EXP) &&
(currtime - m_tsLastRspTime > microseconds_from(PEER_IDLE_TMO_US)))
if (m_bBreakAsUnstable || ((m_iEXPCount > COMM_RESPONSE_MAX_EXP) &&
(currtime - m_tsLastRspTime > microseconds_from(PEER_IDLE_TMO_US))))
{
//
// Connection is broken.
Expand Down
11 changes: 8 additions & 3 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ class CUDT
SRTU_PROPERTY_RR(srt::sync::Condition*, recvDataCond, &m_RecvDataCond);
SRTU_PROPERTY_RR(srt::sync::Condition*, recvTsbPdCond, &m_RcvTsbPdCond);

/// @brief Request a socket to be broken due to too long instability (normally by a group).
void breakAsUnstable() { m_bBreakAsUnstable = true; }

void ConnectSignal(ETransmissionEvent tev, EventSlot sl);
void DisconnectSignal(ETransmissionEvent tev);

Expand Down Expand Up @@ -726,6 +729,7 @@ class CUDT
volatile bool m_bClosing; // If the UDT entity is closing
volatile bool m_bShutdown; // If the peer side has shutdown the connection
volatile bool m_bBroken; // If the connection has been broken
volatile bool m_bBreakAsUnstable; // A flag indicating that the socket should become broken because it has been unstable for too long.
volatile bool m_bPeerHealth; // If the peer status is normal
volatile int m_RejectReason;
bool m_bOpened; // If the UDT entity has been opened
Expand Down Expand Up @@ -908,7 +912,7 @@ class CUDT

srt::sync::Mutex m_SendLock; // used to synchronize "send" call
srt::sync::Mutex m_RcvLossLock; // Protects the receiver loss list (access: CRcvQueue::worker, CUDT::tsbpd)
srt::sync::Mutex m_StatsLock; // used to synchronize access to trace statistics
mutable srt::sync::Mutex m_StatsLock; // used to synchronize access to trace statistics

void initSynch();
void destroySynch();
Expand Down Expand Up @@ -1090,8 +1094,9 @@ class CUDT
static const int PACKETPAIR_MASK = 0xF;

private: // Timers functions
time_point m_tsFreshActivation; // time of fresh activation of the link, or 0 if past the activation phase or idle
time_point m_tsUnstableSince; // time since unexpected ACK delay experienced, or 0 if link seems healthy
time_point m_tsFreshActivation; // GROUPS: time of fresh activation of the link, or 0 if past the activation phase or idle
time_point m_tsUnstableSince; // GROUPS: time since unexpected ACK delay experienced, or 0 if link seems healthy
time_point m_tsWarySince; // GROUPS: time since an unstable link has first some response

static const int BECAUSE_NO_REASON = 0, // NO BITS
BECAUSE_ACK = 1 << 0,
Expand Down
2 changes: 2 additions & 0 deletions srtcore/filelist.maf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ window.cpp

SOURCES - ENABLE_EXPERIMENTAL_BONDING
group.cpp
group_backup.cpp
group_common.cpp

SOURCES - !ENABLE_STDCXX_SYNC
Expand Down Expand Up @@ -76,4 +77,5 @@ window.h

PRIVATE HEADERS - ENABLE_EXPERIMENTAL_BONDING
group.h
group_backup.h
group_common.h
Loading