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

[core] Added locking to setting congestion-window. #1869

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
24 changes: 18 additions & 6 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7054,6 +7054,7 @@ void CUDT::bstats(CBytePerfMon *perf, bool clear, bool instantaneous)
}
}

// [using maybe_locked(m_ConnectionLock, evt == TEV_INIT)]
bool CUDT::updateCC(ETransmissionEvent evt, const EventVariant arg)
{
// Special things that must be done HERE, not in SrtCongestion,
Expand Down Expand Up @@ -7149,22 +7150,33 @@ bool CUDT::updateCC(ETransmissionEvent evt, const EventVariant arg)
// Now execute a congctl-defined action for that event.
EmitSignal(evt, arg);

if (evt == TEV_INIT)
{
// With TEV_INIT, also initialize these fields, just DO NOT LOCK m_ConnectionLock,
// BECAUSE IN THIS CASE IT'S LOCKED ALREADY.
m_tdSendInterval = microseconds_from(m_CongCtl->pktSndPeriod_us());
m_dCongestionWindow = m_CongCtl->cgWindowSize();
}
// This should be done with every event except ACKACK and SEND/RECEIVE
// After any action was done by the congctl, update the congestion window and sending interval.
if (evt != TEV_ACKACK && evt != TEV_SEND && evt != TEV_RECEIVE)
else if (evt != TEV_ACKACK && evt != TEV_SEND && evt != TEV_RECEIVE)
{
// This part comes from original UDT.
// NOTE: THESE things come from CCC class:
// - m_dPktSndPeriod
// - m_dCWndSize
m_tdSendInterval = microseconds_from((int64_t)m_CongCtl->pktSndPeriod_us());
m_dCongestionWindow = m_CongCtl->cgWindowSize();
int64_t sendint = m_CongCtl->pktSndPeriod_us();
double cgwin = m_CongCtl->cgWindowSize();

#if ENABLE_HEAVY_LOGGING
HLOGC(rslog.Debug,
log << CONID() << "updateCC: updated values from congctl: interval=" << count_microseconds(m_tdSendInterval) << " us ("
<< "tk (" << m_CongCtl->pktSndPeriod_us() << "us) cgwindow="
<< std::setprecision(3) << m_dCongestionWindow);
log << CONID() << "updateCC: updating values from congctl: interval=" << sendint
<< " us, cgwindow=" << std::setprecision(3) << cgwin);
#endif

ScopedLock lkc (m_ConnectionLock);
m_tdSendInterval = microseconds_from(sendint);
m_dCongestionWindow = cgwin;
}

HLOGC(rslog.Debug, log << "udpateCC: finished handling for EVENT:" << TransmissionEventStr(evt));
Expand Down