Maximum number of half-open connections can now be changed from program preferences (default is now 50 instead of unlimited)

This commit is contained in:
Christophe Dumez 2010-03-25 19:16:43 +00:00
parent daff6dce4c
commit 63457c034f
6 changed files with 32 additions and 4 deletions

View file

@ -1,3 +1,6 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.3.0
- FEATURE: Max number of half-open connections can now be edited
* Sun Mar 14 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.0
- FEATURE: User can set alternative speed limits for fast toggling
- FEATURE: Bandwidth scheduler (automatically use alternative speed limits for a given period)

View file

@ -1,6 +1,6 @@
[Desktop Entry]
Categories=Qt;Network;P2P;
Comment=V2.2.0
Comment=V2.3.0
Exec=qbittorrent %f
GenericName=Bittorrent client
GenericName[bg]=Торент клиент

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View file

@ -8,14 +8,14 @@
#include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS };
#define ROW_COUNT 9
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN };
#define ROW_COUNT 10
class AdvancedSettings: public QTableWidget {
Q_OBJECT
private:
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh;
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh, *spin_maxhalfopen;
QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts;
public:
@ -45,6 +45,7 @@ public:
delete spin_list_refresh;
delete cb_resolve_countries;
delete cb_resolve_hosts;
delete spin_maxhalfopen;
}
public slots:
@ -65,6 +66,8 @@ public slots:
// Peer resolution
Preferences::resolvePeerCountries(cb_resolve_countries->isChecked());
Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked());
// Max Half-Open connections
Preferences::setMaxHalfOpenConnections(spin_maxhalfopen->value());
}
protected slots:
@ -133,6 +136,13 @@ protected slots:
connect(cb_resolve_hosts, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_resolve_hosts->setChecked(Preferences::resolvePeerHostNames());
setCellWidget(RESOLVE_HOSTS, VALUE, cb_resolve_hosts);
// Max Half Open connections
setItem(MAX_HALF_OPEN, PROPERTY, new QTableWidgetItem(tr("Maximum number of half-open connections [0: Disabled]")));
spin_maxhalfopen = new QSpinBox();
connect(spin_maxhalfopen, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged()));
spin_maxhalfopen->setMinimum(0);
spin_maxhalfopen->setMaximum(99999);
spin_maxhalfopen->setValue(Preferences::getMaxHalfOpenConnections());
}
void emitSettingsChanged() {

View file

@ -445,6 +445,8 @@ void Bittorrent::configureSession() {
// Include overhead in transfer limits
sessionSettings.rate_limit_ip_overhead = Preferences::includeOverheadInLimits();
// Bittorrent
// * Max Half-open connections
s->set_max_half_open_connections(Preferences::getMaxHalfOpenConnections());
// * Max connections limit
setMaxConnections(Preferences::getMaxConnecs());
// * Max connections per torrent limit

View file

@ -916,6 +916,19 @@ public:
settings.setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), resolve);
}
static int getMaxHalfOpenConnections() {
QSettings settings("qBittorrent", "qBittorrent");
const int val = settings.value(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), 50).toInt();
if(val <= 0) return -1;
return val;
}
static void setMaxHalfOpenConnections(int value) {
QSettings settings("qBittorrent", "qBittorrent");
if(value <= 0) value = -1;
settings.setValue(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), value);
}
};
#endif // PREFERENCES_H