diff --git a/src/libsync/bandwidthmanager.cpp b/src/libsync/bandwidthmanager.cpp index 4455514f8..a8dd2a6b1 100644 --- a/src/libsync/bandwidthmanager.cpp +++ b/src/libsync/bandwidthmanager.cpp @@ -53,8 +53,8 @@ BandwidthManager::BandwidthManager(OwncloudPropagator *p) , _relativeLimitCurrentMeasuredJob(nullptr) , _currentDownloadLimit(0) { - _currentUploadLimit = _propagator->_uploadLimit.fetchAndAddAcquire(0); - _currentDownloadLimit = _propagator->_downloadLimit.fetchAndAddAcquire(0); + _currentUploadLimit = _propagator->_uploadLimit; + _currentDownloadLimit = _propagator->_downloadLimit; QObject::connect(&_switchingTimer, &QTimer::timeout, this, &BandwidthManager::switchingTimerExpired); _switchingTimer.setInterval(10 * 1000); @@ -337,7 +337,7 @@ void BandwidthManager::relativeDownloadDelayTimerExpired() void BandwidthManager::switchingTimerExpired() { - qint64 newUploadLimit = _propagator->_uploadLimit.fetchAndAddAcquire(0); + qint64 newUploadLimit = _propagator->_uploadLimit; if (newUploadLimit != _currentUploadLimit) { qCInfo(lcBandwidthManager) << "Upload Bandwidth limit changed" << _currentUploadLimit << newUploadLimit; _currentUploadLimit = newUploadLimit; @@ -354,7 +354,7 @@ void BandwidthManager::switchingTimerExpired() } } } - qint64 newDownloadLimit = _propagator->_downloadLimit.fetchAndAddAcquire(0); + qint64 newDownloadLimit = _propagator->_downloadLimit; if (newDownloadLimit != _currentDownloadLimit) { qCInfo(lcBandwidthManager) << "Download Bandwidth limit changed" << _currentDownloadLimit << newDownloadLimit; _currentDownloadLimit = newDownloadLimit; diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index ed9eeea41..b895da128 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -79,8 +79,8 @@ OwncloudPropagator::~OwncloudPropagator() = default; int OwncloudPropagator::maximumActiveTransferJob() { - if (_downloadLimit.fetchAndAddAcquire(0) != 0 - || _uploadLimit.fetchAndAddAcquire(0) != 0 + if (_downloadLimit != 0 + || _uploadLimit != 0 || !_syncOptions._parallelNetworkJobs) { // disable parallelism when there is a network limit. return 1; @@ -237,8 +237,8 @@ void PropagateItemJob::done(SyncFileItem::Status statusArg, const QString &error } } - if (propagator()->_abortRequested.fetchAndAddRelaxed(0) && (_item->_status == SyncFileItem::NormalError - || _item->_status == SyncFileItem::FatalError)) { + if (propagator()->_abortRequested && (_item->_status == SyncFileItem::NormalError + || _item->_status == SyncFileItem::FatalError)) { // an abort request is ongoing. Change the status to Soft-Error _item->_status = SyncFileItem::SoftError; } diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 2cc537d5b..4524e893c 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -419,11 +419,11 @@ public: const SyncOptions &syncOptions() const; void setSyncOptions(const SyncOptions &syncOptions); - QAtomicInt _downloadLimit; - QAtomicInt _uploadLimit; + int _downloadLimit = 0; + int _uploadLimit = 0; BandwidthManager _bandwidthManager; - QAtomicInt _abortRequested; // boolean set by the main thread to abort. + bool _abortRequested = false; /** The list of currently active jobs. This list contains the jobs that are currently using ressources and is used purely to @@ -492,8 +492,7 @@ public: void abort() { - bool alreadyAborting = _abortRequested.fetchAndStoreOrdered(true); - if (alreadyAborting) + if (_abortRequested) return; if (_rootJob) { // Connect to abortFinished which signals that abort has been asynchronously finished diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index bdd250cee..b630778c8 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -361,7 +361,7 @@ QString GETFileJob::errorString() const void PropagateDownloadFile::start() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; _isEncrypted = false; @@ -503,7 +503,7 @@ void PropagateDownloadFile::conflictChecksumComputed(const QByteArray &checksumT void PropagateDownloadFile::startDownload() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; // do a klaas' case clash check. diff --git a/src/libsync/propagateremotedelete.cpp b/src/libsync/propagateremotedelete.cpp index 848d94328..6b8776cd0 100644 --- a/src/libsync/propagateremotedelete.cpp +++ b/src/libsync/propagateremotedelete.cpp @@ -81,7 +81,7 @@ PropagatorJob::JobParallelism PropagateRemoteDelete::parallelism() void PropagateRemoteDelete::start() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; if (!_item->_encryptedFileName.isEmpty()) { diff --git a/src/libsync/propagateremotemkdir.cpp b/src/libsync/propagateremotemkdir.cpp index 945d7d393..006f1cdc8 100644 --- a/src/libsync/propagateremotemkdir.cpp +++ b/src/libsync/propagateremotemkdir.cpp @@ -69,7 +69,7 @@ PropagatorJob::JobParallelism PropagateRemoteMkdir::parallelism() void PropagateRemoteMkdir::start() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; qCDebug(lcPropagateRemoteMkdir) << _item->_file; @@ -91,7 +91,7 @@ void PropagateRemoteMkdir::start() void PropagateRemoteMkdir::slotStartMkcolJob() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; qCDebug(lcPropagateRemoteMkdir) << _item->_file; @@ -108,7 +108,7 @@ void PropagateRemoteMkdir::slotStartEncryptedMkcolJob(const QString &path, const Q_UNUSED(path) Q_UNUSED(size) - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; qDebug() << filename; diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index 889fb7b1d..0d7f57ce3 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -75,7 +75,7 @@ bool MoveJob::finished() void PropagateRemoteMove::start() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; QString origin = propagator()->adjustRenamedPath(_item->_file); diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index f17fc5367..519fb36c9 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -293,7 +293,7 @@ void PropagateUploadFileCommon::setupUnencryptedFile() } void PropagateUploadFileCommon::startUploadFile() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) { + if (propagator()->_abortRequested) { return; } @@ -335,7 +335,7 @@ void PropagateUploadFileCommon::slotComputeContentChecksum() { qDebug() << "Trying to compute the checksum of the file"; qDebug() << "Still trying to understand if this is the local file or the uploaded one"; - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) { + if (propagator()->_abortRequested) { return; } diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index fa79633d1..29c549ea0 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -275,7 +275,7 @@ void PropagateUploadFileNG::slotMkColFinished(QNetworkReply::NetworkError) void PropagateUploadFileNG::startNextChunk() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; qint64 fileSize = _fileToUpload._size; diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index e1ae8b5fa..93950c313 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -72,7 +72,7 @@ void PropagateUploadFileV1::doStartUpload() void PropagateUploadFileV1::startNextChunk() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; if (!_jobs.isEmpty() && _currentChunk + _startChunk >= _chunkCount - 1) { diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 8324e6f3a..730694c0a 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -92,7 +92,7 @@ void PropagateLocalRemove::start() { _moveToTrash = propagator()->syncOptions()._moveFilesToTrash; - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; QString filename = propagator()->_localDir + _item->_file; @@ -132,7 +132,7 @@ void PropagateLocalRemove::start() void PropagateLocalMkdir::start() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; const auto rootPath = [=]() { @@ -244,7 +244,7 @@ void PropagateLocalMkdir::startDemanglingName(const QString &parentPath) void PropagateLocalRename::start() { - if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) + if (propagator()->_abortRequested) return; QString existingFile = propagator()->getFilePath(propagator()->adjustRenamedPath(_item->_file)); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 48bc8ac5a..3cc77c52e 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -822,11 +822,8 @@ void SyncEngine::setNetworkLimits(int upload, int download) _propagator->_uploadLimit = upload; _propagator->_downloadLimit = download; - int propDownloadLimit = _propagator->_downloadLimit.load(); - int propUploadLimit = _propagator->_uploadLimit.load(); - - if (propDownloadLimit != 0 || propUploadLimit != 0) { - qCInfo(lcEngine) << "Network Limits (down/up) " << propDownloadLimit << propUploadLimit; + if (upload != 0 || download != 0) { + qCInfo(lcEngine) << "Network Limits (down/up) " << upload << download; } }