Skip to content

Commit

Permalink
[core] Minor: renamed CUDT m_tsTmpActiveSince to m_tsFreshActivation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored Feb 1, 2021
1 parent 17db0cb commit 481e7f7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ void CUDT::open()

m_iReXmitCount = 1;
m_tsUnstableSince = steady_clock::time_point();
m_tsTmpActiveSince = steady_clock::time_point();
m_tsFreshActivation = steady_clock::time_point();
m_iPktCount = 0;
m_iLightACKCount = 1;

Expand Down Expand Up @@ -5763,7 +5763,7 @@ void *CUDT::tsbpd(void *param)

if (!is_zero(tsbpdtime))
{
const steady_clock::duration timediff = tsbpdtime - steady_clock::now();
IF_HEAVY_LOGGING(const steady_clock::duration timediff = tsbpdtime - steady_clock::now());
/*
* Buffer at head of queue is not ready to play.
* Schedule wakeup when it will be.
Expand Down
4 changes: 2 additions & 2 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,8 @@ class CUDT
static const size_t MAX_SID_LENGTH = 512;

private: // Timers functions
time_point m_tsTmpActiveSince; // time since temporary activated, or 0 if not temporary activated
time_point m_tsUnstableSince; // time since unexpected ACK delay experienced, or 0 if link seems healthy
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

static const int BECAUSE_NO_REASON = 0, // NO BITS
BECAUSE_ACK = 1 << 0,
Expand Down
39 changes: 20 additions & 19 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2973,15 +2973,15 @@ void CUDTGroup::sendBackup_CheckIdleTime(gli_t w_d)
// buffer gets empty so that we can make sure that KEEPALIVE will be the
// really last sent for longer time.
CUDT& u = w_d->ps->core();
if (is_zero(u.m_tsTmpActiveSince))
if (is_zero(u.m_tsFreshActivation))
return;

CSndBuffer* b = u.m_pSndBuffer;
if (b && b->getCurrBufSize() == 0)
{
HLOGC(gslog.Debug,
log << "grp/sendBackup: FRESH IDLE LINK reached empty buffer - setting permanent and KEEPALIVE");
u.m_tsTmpActiveSince = steady_clock::time_point();
u.m_tsFreshActivation = steady_clock::time_point();

// Send first immediate keepalive. The link is to be turn to IDLE
// now so nothing will be sent to it over time and it will start
Expand Down Expand Up @@ -3015,7 +3015,7 @@ bool CUDTGroup::sendBackup_CheckRunningStability(const gli_t d, const time_point
log << "grp/sendBackup: CHECK STABLE: @" << d->id
<< ": TIMEDIFF {response= " << FormatDuration<DUNIT_MS>(currtime - u.m_tsLastRspTime)
<< " ACK=" << FormatDuration<DUNIT_MS>(currtime - u.m_tsLastRspAckTime) << " activation="
<< (!is_zero(u.m_tsTmpActiveSince) ? FormatDuration<DUNIT_MS>(currtime - u.m_tsTmpActiveSince) : "PAST")
<< (!is_zero(u.m_tsFreshActivation) ? FormatDuration<DUNIT_MS>(currtime - u.m_tsFreshActivation) : "PAST")
<< " unstable="
<< (!is_zero(u.m_tsUnstableSince) ? FormatDuration<DUNIT_MS>(currtime - u.m_tsUnstableSince) : "NEVER")
<< "}");
Expand All @@ -3026,7 +3026,7 @@ bool CUDTGroup::sendBackup_CheckRunningStability(const gli_t d, const time_point
const steady_clock::duration td_responsive = currtime - u.m_tsLastRspTime;
bool check_stability = true;

if (!is_zero(u.m_tsTmpActiveSince) && u.m_tsTmpActiveSince < currtime)
if (!is_zero(u.m_tsFreshActivation) && u.m_tsFreshActivation < currtime)
{
// The link is temporary-activated. Calculate then since the activation time.

Expand All @@ -3053,7 +3053,7 @@ bool CUDTGroup::sendBackup_CheckRunningStability(const gli_t d, const time_point

// As we DO have activation time, we need to check if there's at least
// one ACK newer than activation, that is, td_acked < td_active
if (u.m_tsLastRspAckTime < u.m_tsTmpActiveSince)
if (u.m_tsLastRspAckTime < u.m_tsFreshActivation)
{
check_stability = false;
HLOGC(gslog.Debug,
Expand All @@ -3063,7 +3063,7 @@ bool CUDTGroup::sendBackup_CheckRunningStability(const gli_t d, const time_point
}
else
{
u.m_tsTmpActiveSince = steady_clock::time_point();
u.m_tsFreshActivation = steady_clock::time_point();
}
}

Expand Down Expand Up @@ -3122,6 +3122,7 @@ bool CUDTGroup::sendBackup_CheckSendStatus(gli_t
{
bool none_succeeded = true;

// sending over this socket has succeeded
if (stat != -1)
{
if (w_curseq == SRT_SEQNO_NONE)
Expand Down Expand Up @@ -3380,7 +3381,7 @@ size_t CUDTGroup::sendBackup_TryActivateIdleLink(const vector<gli_t>& i
if (d->sndstate != SRT_GST_RUNNING)
{
steady_clock::time_point currtime = steady_clock::now();
d->ps->core().m_tsTmpActiveSince = currtime;
d->ps->core().m_tsFreshActivation = currtime;
HLOGC(gslog.Debug,
log << "@" << d->id << ":... sending SUCCESSFUL #" << w_mc.msgno
<< " LINK ACTIVATED (pri: " << d->weight << ").");
Expand Down Expand Up @@ -3535,7 +3536,7 @@ struct FByOldestActive
CUDT& x = a->ps->core();
CUDT& y = b->ps->core();

return x.m_tsTmpActiveSince < y.m_tsTmpActiveSince;
return x.m_tsFreshActivation < y.m_tsFreshActivation;
}
};

Expand Down Expand Up @@ -3736,7 +3737,7 @@ void CUDTGroup::sendBackup_RetryWaitBlocked(const vector<gli_t>& unstableLinks,
w_parallel.push_back(d);
w_final_stat = stat;
steady_clock::time_point currtime = steady_clock::now();
d->ps->core().m_tsTmpActiveSince = currtime;
d->ps->core().m_tsFreshActivation = currtime;
d->sndstate = SRT_GST_RUNNING;
w_none_succeeded = false;
HLOGC(gslog.Debug, log << "grp/sendBackup: after waiting, ACTIVATED link @" << d->id);
Expand Down Expand Up @@ -3826,19 +3827,19 @@ void CUDTGroup::sendBackup_SilenceRedundantLinks(const vector<gli_t>& unstableLi
}
CUDT& ce = d->ps->core();
steady_clock::duration td(0);
if (!is_zero(ce.m_tsTmpActiveSince) &&
count_microseconds(td = currtime - ce.m_tsTmpActiveSince) < ce.m_uOPT_StabilityTimeout)
if (!is_zero(ce.m_tsFreshActivation) &&
count_microseconds(td = currtime - ce.m_tsFreshActivation) < ce.m_uOPT_StabilityTimeout)
{
HLOGC(gslog.Debug,
log << "... not silencing @" << d->id << ": too early: " << FormatDuration(td) << " < "
<< ce.m_uOPT_StabilityTimeout << "(stability timeout)");
log << "... not silencing @" << d->id << ": too early: " << FormatDuration(td) << " < "
<< ce.m_uOPT_StabilityTimeout << "(stability timeout)");
continue;
}

// Clear activation time because the link is no longer active!
d->sndstate = SRT_GST_IDLE;
HLOGC(gslog.Debug, log << " ... @" << d->id << " ACTIVATED: " << FormatTime(ce.m_tsTmpActiveSince));
ce.m_tsTmpActiveSince = steady_clock::time_point();
HLOGC(gslog.Debug, log << " ... @" << d->id << " ACTIVATED: " << FormatTime(ce.m_tsFreshActivation));
ce.m_tsFreshActivation = steady_clock::time_point();
}
}

Expand Down Expand Up @@ -3921,8 +3922,8 @@ int CUDTGroup::sendBackup(const char* buf, int len, SRT_MSGCTRL& w_mc)

bool none_succeeded = true; // be pessimistic

// This should be added all sockets that are currently stable
// and sending was successful. Later, all but the one with highest
// All sockets that are currently stable and sending was successful
// should be added to the vector. Later, all but the one with highest
// priority should remain active.
vector<gli_t> parallel;

Expand Down Expand Up @@ -4355,7 +4356,7 @@ void CUDTGroup::handleKeepalive(CUDTGroup::SocketData* gli)
// which may result not only with exceeded stability timeout (which fortunately
// isn't being measured in this case), but also with receiveing keepalive
// (therefore we also don't reset the link to IDLE in the temporary activation period).
if (gli->sndstate == SRT_GST_RUNNING && is_zero(gli->ps->core().m_tsTmpActiveSince))
if (gli->sndstate == SRT_GST_RUNNING && is_zero(gli->ps->core().m_tsFreshActivation))
{
gli->sndstate = SRT_GST_IDLE;
HLOGC(gslog.Debug,
Expand All @@ -4375,7 +4376,7 @@ void CUDTGroup::internalKeepalive(SocketData* gli)
{
gli->rcvstate = SRT_GST_IDLE;
// Prevent sending KEEPALIVE again in group-sending
gli->ps->core().m_tsTmpActiveSince = steady_clock::time_point();
gli->ps->core().m_tsFreshActivation = steady_clock::time_point();
HLOGC(gslog.Debug, log << "GROUP: EXP-requested KEEPALIVE in @" << gli->id << " - link turning IDLE");
}
}
Expand Down

0 comments on commit 481e7f7

Please sign in to comment.