lt sync 2432

Add new queueing options
This commit is contained in:
Andrew Resch 2008-06-21 19:02:15 +00:00
parent f921834d4f
commit aad8a926d6
9 changed files with 377 additions and 237 deletions

View File

@ -92,7 +92,9 @@ DEFAULT_PREFS = {
"autoadd_enable": False,
"add_paused": False,
"max_active_seeding": 5,
"max_active_downloading": 8,
"max_active_downloading": 3,
"max_active_limit": 8,
"dont_count_slow_torrents": False,
"queue_new_to_top": False,
"stop_seed_at_ratio": False,
"remove_seed_at_ratio": False,
@ -251,6 +253,10 @@ class Core(
self._on_set_max_active_downloading)
self.config.register_set_function("max_active_seeding",
self._on_set_max_active_seeding)
self.config.register_set_function("max_active_limit",
self._on_set_max_active_limit)
self.config.register_set_function("dont_count_slow_torrents",
self._on_set_dont_count_slow_torrents)
self.config.register_change_callback(self._on_config_value_change)
# Start the AlertManager
@ -792,3 +798,14 @@ class Core(
self.settings.active_seeds = value
self.session.set_settings(self.settings)
def _on_set_max_active_limit(self, key, value):
log.debug("%s set to %s..", key, value)
log.debug("active_limit: %s", self.settings.active_limit)
self.settings.active_limit = value
self.session.set_settings(self.settings)
def _on_set_dont_count_slow_torrents(self, key, value):
log.debug("%s set to %s..", key, value)
self.settings.dont_count_slow_torrents = value
self.session.set_settings(self.settings)

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Tue Jun 17 08:59:23 2008 -->
<!--Generated with glade3 3.4.4 on Sat Jun 21 11:34:32 2008 -->
<glade-interface>
<widget class="GtkDialog" id="pref_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -1158,40 +1158,71 @@ Disabled</property>
<property name="n_columns">2</property>
<property name="column_spacing">15</property>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload">
<widget class="GtkSpinButton" id="spin_max_connections_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="max_length">4</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="digits">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum download speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -1216,74 +1247,43 @@ Disabled</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<widget class="GtkSpinButton" id="spin_max_upload">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum download speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_global">
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="max_length">4</property>
<property name="tooltip" translatable="yes">The maximum upload slots for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -1327,85 +1327,18 @@ Disabled</property>
<property name="n_columns">2</property>
<property name="column_spacing">15</property>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_per_torrent">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_per_torrent">
<widget class="GtkSpinButton" id="spin_max_upload_per_torrent">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="snap_to_ticks">True</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label31">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label32">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
@ -1430,20 +1363,87 @@ Disabled</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_per_torrent">
<widget class="GtkLabel" id="label32">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label31">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_per_torrent">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="digits">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_per_torrent">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -2202,11 +2202,15 @@ Disabled</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox20">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">2</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<child>
@ -2251,6 +2255,18 @@ Disabled</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label27">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Total active seeding:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_seeding">
<property name="visible">True</property>
@ -2264,9 +2280,41 @@ Disabled</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_active">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">1</property>
<property name="adjustment">0 -1 9999 1 10 10</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"></property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkCheckButton" id="chk_dont_count_slow_torrents">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Do not count slow torrents</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -2313,51 +2361,18 @@ Disabled</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<child>
<widget class="GtkLabel" id="label53">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Share Ratio Limit:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label54">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Seed Time Ratio:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label55">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Seed Time (m):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_share_ratio_limit">
<widget class="GtkSpinButton" id="spin_seed_time_limit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="xalign">1</property>
<property name="adjustment">1.5 -1 100 0.10000000000000001 10 10</property>
<property name="digits">2</property>
<property name="adjustment">6 -1 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
</packing>
</child>
@ -2379,19 +2394,52 @@ Disabled</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_seed_time_limit">
<widget class="GtkSpinButton" id="spin_share_ratio_limit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="xalign">1</property>
<property name="adjustment">6 -1 100 1 10 10</property>
<property name="adjustment">1.5 -1 100 0.10000000000000001 10 10</property>
<property name="digits">2</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label55">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Seed Time (m):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label54">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Seed Time Ratio:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label53">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Share Ratio Limit:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>

View File

@ -241,8 +241,10 @@ class Preferences(component.Component):
("value", self.core_config["daemon_port"]),
"chk_allow_remote_connections": \
("active", self.core_config["allow_remote"]),
"spin_active": ("value", self.core_config["max_active_limit"]),
"spin_seeding": ("value", self.core_config["max_active_seeding"]),
"spin_downloading": ("value", self.core_config["max_active_downloading"]),
"chk_dont_count_slow_torrents": ("active", self.core_config["dont_count_slow_torrents"]),
"chk_queue_new_top": ("active", self.core_config["queue_new_to_top"]),
"spin_share_ratio_limit": ("value", self.core_config["share_ratio_limit"]),
"spin_seed_time_ratio_limit": \
@ -345,6 +347,8 @@ class Preferences(component.Component):
"chk_allow_remote_connections",
"spin_seeding",
"spin_downloading",
"spin_active",
"chk_dont_count_slow_torrents",
"chk_queue_new_top",
"chk_seed_ratio",
"spin_share_ratio",
@ -532,6 +536,10 @@ class Preferences(component.Component):
self.glade.get_widget("spin_seeding").get_value_as_int()
new_core_config["max_active_downloading"] = \
self.glade.get_widget("spin_downloading").get_value_as_int()
new_core_config["max_active_limit"] = \
self.glade.get_widget("spin_active").get_value_as_int()
new_core_config["dont_count_slow_torrents"] = \
self.glade.get_widget("chk_dont_count_slow_torrents").get_active()
new_core_config["stop_seed_at_ratio"] = \
self.glade.get_widget("chk_seed_ratio").get_active()
new_core_config["remove_seed_at_ratio"] = \

View File

@ -36,6 +36,8 @@ void bind_session_settings()
.def_readwrite("unchoke_interval", &session_settings::unchoke_interval)
.def_readwrite("active_downloads", &session_settings::active_downloads)
.def_readwrite("active_seeds", &session_settings::active_seeds)
.def_readwrite("active_limit", &session_settings::active_limit)
.def_readwrite("dont_count_slow_torrents", &session_settings::dont_count_slow_torrents)
.def_readwrite("auto_manage_interval", &session_settings::auto_manage_interval)
.def_readwrite("share_ratio_limit", &session_settings::share_ratio_limit)
.def_readwrite("seed_time_ratio_limit", &session_settings::seed_time_ratio_limit)

View File

@ -126,6 +126,8 @@ namespace libtorrent
, peer_tos(0)
, active_downloads(8)
, active_seeds(5)
, active_limit(15)
, dont_count_slow_torrents(true)
, auto_manage_interval(30)
, share_ratio_limit(2.f)
, seed_time_ratio_limit(7.f)
@ -362,6 +364,12 @@ namespace libtorrent
// some slots free up.
int active_downloads;
int active_seeds;
int active_limit;
// if this is true, torrents that don't have any significant
// transfers are not counted as active when determining which
// auto managed torrents to pause and resume
bool dont_count_slow_torrents;
// the number of seconds in between recalculating which
// torrents to activate and which ones to queue

View File

@ -69,9 +69,11 @@ class upnp : public intrusive_ptr_base<upnp>
public:
upnp(io_service& ios, connection_queue& cc
, address const& listen_interface, std::string const& user_agent
, portmap_callback_t const& cb, bool ignore_nonrouters);
, portmap_callback_t const& cb, bool ignore_nonrouters, void* state = 0);
~upnp();
void* drain_state();
enum protocol_type { none = 0, udp = 1, tcp = 2 };
int add_mapping(protocol_type p, int external_port, int local_port);
void delete_mapping(int mapping_index);
@ -226,6 +228,12 @@ private:
{ return url < rhs.url; }
};
struct upnp_state_t
{
std::vector<global_mapping_t> mappings;
std::set<rootdevice> devices;
};
std::vector<global_mapping_t> m_mappings;
std::string const& m_user_agent;

View File

@ -1295,6 +1295,16 @@ namespace aux {
}
}
namespace
{
bool is_active(torrent* t, session_settings const& s)
{
return !(s.dont_count_slow_torrents
&& t->statistics().upload_payload_rate() == 0.f
&& t->statistics().download_payload_rate() == 0.f);
}
}
void session_impl::recalculate_auto_managed_torrents()
{
// these vectors are filled with auto managed torrents
@ -1307,6 +1317,7 @@ namespace aux {
// of each kind we're allowed to have active
int num_downloaders = settings().active_downloads;
int num_seeds = settings().active_seeds;
int hard_limit = settings().active_limit;
if (num_downloaders == -1)
num_downloaders = (std::numeric_limits<int>::max)();
@ -1328,14 +1339,18 @@ namespace aux {
downloaders.push_back(t);
}
else if (!t->is_paused())
{
--hard_limit;
if (is_active(t, settings()))
{
// this is not an auto managed torrent,
// if it's running, decrease the respective
// if it's running and active, decrease the
// counters.
--num_downloaders;
--num_seeds;
}
}
}
bool handled_by_extension = false;
@ -1357,8 +1372,15 @@ namespace aux {
, end(downloaders.end()); i != end; ++i)
{
torrent* t = *i;
if (num_downloaders > 0)
if (!t->is_paused() && !is_active(t, settings()) && hard_limit > 0)
{
--hard_limit;
continue;
}
if (num_downloaders > 0 && hard_limit > 0)
{
--hard_limit;
if (t->state() != torrent_status::queued_for_checking
&& t->state() != torrent_status::checking_files)
{
@ -1377,8 +1399,15 @@ namespace aux {
, end(seeds.end()); i != end; ++i)
{
torrent* t = *i;
if (num_seeds > 0)
if (!t->is_paused() && !is_active(t, settings()) && hard_limit > 0)
{
--hard_limit;
continue;
}
if (num_seeds > 0 && hard_limit > 0)
{
--hard_limit;
--num_downloaders;
--num_seeds;
if (t->is_paused()) t->resume();

View File

@ -3420,7 +3420,7 @@ namespace libtorrent
session_impl::torrent_map& torrents = m_ses.m_torrents;
if (p >= 0 && m_sequence_number == -1)
{
int max_seq = 0;
int max_seq = -1;
for (session_impl::torrent_map::iterator i = torrents.begin()
, end(torrents.end()); i != end; ++i)
{

View File

@ -61,7 +61,7 @@ using namespace libtorrent;
upnp::upnp(io_service& ios, connection_queue& cc
, address const& listen_interface, std::string const& user_agent
, portmap_callback_t const& cb, bool ignore_nonrouters)
, portmap_callback_t const& cb, bool ignore_nonrouters, void* state)
: m_user_agent(user_agent)
, m_callback(cb)
, m_retry_count(0)
@ -79,6 +79,26 @@ upnp::upnp(io_service& ios, connection_queue& cc
m_log.open("upnp.log", std::ios::in | std::ios::out | std::ios::trunc);
#endif
m_retry_count = 0;
if (state)
{
upnp_state_t* s = (upnp_state_t*)s;
m_devices.swap(s->devices);
m_mappings.swap(s->mappings);
delete s;
}
}
void* upnp::drain_state()
{
upnp_state_t* s = new upnp_state_t;
s->mappings.swap(m_mappings);
for (std::set<rootdevice>::iterator i = m_devices.begin()
, end(m_devices.end()); i != end; ++i)
i->upnp_connection.reset();
s->devices.swap(m_devices);
return s;
}
upnp::~upnp()