From 475117dd6001fc7b29d13ee4405c609c74a4d354 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 30 Aug 2019 11:37:07 +0200 Subject: [PATCH] Propagator: Make sure we schedule only one job #7439 To not starve the event loop. (There is still ~= 3 jobs running at the same time) --- src/libsync/owncloudpropagator.cpp | 5 +++++ src/libsync/owncloudpropagator.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 83b067270..856b2e25f 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -487,6 +487,7 @@ void OwncloudPropagator::start(const SyncFileItemVector &items) connect(_rootJob.data(), &PropagatorJob::finished, this, &OwncloudPropagator::emitFinished); + _jobScheduled = false; scheduleNextJob(); } @@ -587,6 +588,8 @@ QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const void OwncloudPropagator::scheduleNextJob() { + if (_jobScheduled) return; // don't schedule more than 1 + _jobScheduled = true; QTimer::singleShot(0, this, &OwncloudPropagator::scheduleNextJobImpl); } @@ -597,6 +600,8 @@ void OwncloudPropagator::scheduleNextJobImpl() // Down-scaling on slow networks? https://github.com/owncloud/client/issues/3382 // Making sure we do up/down at same time? https://github.com/owncloud/client/issues/1633 + _jobScheduled = false; + if (_activeJobList.count() < maximumActiveTransferJob()) { if (_rootJob->scheduleSelfOrChild()) { scheduleNextJob(); diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 0febc6ab7..c5431f051 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -567,6 +567,7 @@ private: AccountPtr _account; QScopedPointer _rootJob; SyncOptions _syncOptions; + bool _jobScheduled = false; };