]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Upload: put the job in the active list while doing the checksum computation.
authorOlivier Goffart <ogoffart@woboq.com>
Fri, 20 May 2016 13:06:07 +0000 (15:06 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Fri, 20 May 2016 14:28:27 +0000 (16:28 +0200)
This fixes an issue in which too many jobs are started un parallel
while uploading many files, which could cause too much memory usage as the
chunks are stored in memory.

Probably the fix for #4611

src/libsync/owncloudpropagator.h
src/libsync/propagateupload.cpp

index 85fa42617cc38774f62c6a6ce93fe5dc7f06bf23..6dcfd565e45dcc40d0a3157151b6e6f97dfd41f7 100644 (file)
@@ -297,7 +297,12 @@ public:
 
     QAtomicInt _abortRequested; // boolean set by the main thread to abort.
 
-    /* The list of currently active jobs */
+    /** The list of currently active jobs.
+        This list contains the jobs that are currently using ressources and is used purely to
+        know how many jobs there is currently running for the scheduler.
+        Jobs add themself to the list when they do an assynchronous operation.
+        Jobs can be several time on the list (example, when several chunks are uploaded in parallel)
+     */
     QList<PropagateItemJob*> _activeJobList;
 
     /** We detected that another sync is required after this one */
index bd2f29b96588404c0d05fb2f830ecd166e80f261..9f983311129698d4ad6638160a83fe92489a8415 100644 (file)
@@ -209,8 +209,6 @@ void PropagateUploadFileQNAM::slotComputeContentChecksum()
         return;
     }
 
-    _propagator->_activeJobList.removeOne(this);
-
     const QString filePath = _propagator->getFilePath(_item->_file);
 
     // remember the modtime before checksumming to be able to detect a file
@@ -274,6 +272,10 @@ void PropagateUploadFileQNAM::slotComputeTransmissionChecksum(const QByteArray&
 
 void PropagateUploadFileQNAM::slotStartUpload(const QByteArray& transmissionChecksumType, const QByteArray& transmissionChecksum)
 {
+    // Remove ourselfs from the list of active job, before any posible call to done()
+    // When we start chunks, we will add it again, once for every chunks.
+    _propagator->_activeJobList.removeOne(this);
+
     _transmissionChecksum = transmissionChecksum;
     _transmissionChecksumType = transmissionChecksumType;