Fix deadlock when using putmultifilejob with rate limits enabled
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 15 May 2023 11:30:27 +0000 (19:30 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 15 May 2023 12:46:21 +0000 (20:46 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/libsync/putmultifilejob.cpp

index f3740a17cc0ec4b1cc7ef059b64d18c86a2dd710..05edda06a0516839264ea642bab2f0b27485e2d3 100644 (file)
@@ -44,6 +44,13 @@ void PutMultiFileJob::start()
     QNetworkRequest req;
 
     for(const auto &oneDevice : _devices) {
+        // Our rate limits in UploadDevice::readData will cause an application freeze if used here.
+        // QHttpMultiPart's internal QHttpMultiPartIODevice::readData will loop over and over trying
+        // to read data from our UploadDevice while there is data left to be read; this will cause
+        // a deadlock as we will never have a chance to progress the data read
+        oneDevice._device->setChoked(false);
+        oneDevice._device->setBandwidthLimited(false);
+
         auto onePart = QHttpPart{};
 
         onePart.setBodyDevice(oneDevice._device.get());