Skip to content

Commit

Permalink
Modernise and improve readability of BandwidthManager::relativeUpload…
Browse files Browse the repository at this point in the history
…DelayTimerExpired

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra authored and backportbot-nextcloud[bot] committed May 15, 2023
1 parent 6fcf94d commit 87b6503
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/libsync/bandwidthmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,21 @@ void BandwidthManager::relativeUploadDelayTimerExpired()
_relativeUploadDeviceList.pop_front();
_relativeUploadDeviceList.push_back(_relativeLimitCurrentMeasuredDevice);

_relativeUploadLimitProgressAtMeasuringRestart = (_relativeLimitCurrentMeasuredDevice->_readWithProgress
+ _relativeLimitCurrentMeasuredDevice->_read)
/ 2;
const auto currentReadWithProgress = _relativeLimitCurrentMeasuredDevice->_readWithProgress;
const auto currentRead = _relativeLimitCurrentMeasuredDevice->_read;
_relativeUploadLimitProgressAtMeasuringRestart = (currentReadWithProgress + currentRead) / 2;

_relativeLimitCurrentMeasuredDevice->setBandwidthLimited(false);
_relativeLimitCurrentMeasuredDevice->setChoked(false);

// choke all other UploadDevices
Q_FOREACH (UploadDevice *ud, _relativeUploadDeviceList) {
if (ud != _relativeLimitCurrentMeasuredDevice) {
ud->setBandwidthLimited(true);
ud->setChoked(true);
for (const auto uploadDevice : _relativeUploadDeviceList) {
if (uploadDevice == _relativeLimitCurrentMeasuredDevice) {
continue;
}

uploadDevice->setBandwidthLimited(true);
uploadDevice->setChoked(true);
}

// now we're in measuring state
Expand Down

0 comments on commit 87b6503

Please sign in to comment.