From fa6628e7eb8ffda609567ad5a86b6b897903090d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 31 Jul 2015 16:52:09 -0700 Subject: [PATCH] make sure we init CongestionControl --- libraries/networking/src/udt/CongestionControl.cpp | 6 ++++-- libraries/networking/src/udt/Connection.cpp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/udt/CongestionControl.cpp b/libraries/networking/src/udt/CongestionControl.cpp index 984d520d07..8d8efec51e 100644 --- a/libraries/networking/src/udt/CongestionControl.cpp +++ b/libraries/networking/src/udt/CongestionControl.cpp @@ -18,11 +18,13 @@ using namespace std::chrono; static const double USECS_PER_SECOND = 1000000.0; void CongestionControl::setPacketSendPeriod(double newSendPeriod) { + Q_ASSERT_X(newSendPeriod >= 0, "CongestionControl::setPacketPeriod", "Can not set a negative packet send period"); + if (_maxBandwidth > 0) { // anytime the packet send period is about to be increased, make sure it stays below the minimum period, // calculated based on the maximum desired bandwidth - int minPacketSendPeriod = USECS_PER_SECOND / (double(_maxBandwidth) / _mss); - _packetSendPeriod = std::max(newSendPeriod, (double) minPacketSendPeriod); + double minPacketSendPeriod = USECS_PER_SECOND / (((double) _maxBandwidth) / _mss); + _packetSendPeriod = std::max(newSendPeriod, minPacketSendPeriod); } else { _packetSendPeriod = newSendPeriod; } diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index d668ed09fb..8b16e8987f 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -32,6 +32,9 @@ Connection::Connection(Socket* parentSocket, HifiSockAddr destination, unique_pt { Q_ASSERT_X(socket, "Connection::Connection", "Must be called with a valid Socket*"); + Q_ASSERT_X(congestionControl, "Connection::Connection", "Must be called with a valid CongestionControl object"); + congestionControl->init(); + // setup default SYN, RTT and RTT Variance based on the SYN interval in CongestionControl object _synInterval = _congestionControl->synInterval(); _rtt = _synInterval * 10;