mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
BUGFIX: Limit the number of concurrent download threads to save memory
This commit is contained in:
parent
fed63b0b85
commit
cc4a542e9d
2 changed files with 10 additions and 1 deletions
|
@ -24,6 +24,8 @@
|
|||
#include <QSettings>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_THREADS 3
|
||||
|
||||
// http://curl.rtin.bz/libcurl/c/libcurl-errors.html
|
||||
QString subDownloadThread::errorCodeToString(CURLcode status) {
|
||||
switch(status){
|
||||
|
@ -165,7 +167,7 @@ void downloadThread::run(){
|
|||
if(abort)
|
||||
return;
|
||||
mutex.lock();
|
||||
if(url_list.size() != 0){
|
||||
if(url_list.size() != 0 && subThreads.size() < MAX_THREADS){
|
||||
QString url = url_list.takeFirst();
|
||||
mutex.unlock();
|
||||
subDownloadThread *st = new subDownloadThread(0, url);
|
||||
|
@ -190,6 +192,9 @@ void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url,
|
|||
index = downloading_list.indexOf(url);
|
||||
Q_ASSERT(index != -1);
|
||||
downloading_list.removeAt(index);
|
||||
if(url_list.size() != 0) {
|
||||
condition.wakeOne();
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
|
@ -203,5 +208,8 @@ void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url
|
|||
index = downloading_list.indexOf(url);
|
||||
Q_ASSERT(index != -1);
|
||||
downloading_list.removeAt(index);
|
||||
if(url_list.size() != 0) {
|
||||
condition.wakeOne();
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue