From 5455b869b2ab97fdd7c078a0cf9214db7a0c81f5 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 28 Dec 2009 19:15:48 +0000 Subject: [PATCH] download-throttle config var --- panda/src/downloader/config_downloader.cxx | 21 ++++++++++++--------- panda/src/downloader/config_downloader.h | 2 +- panda/src/downloader/httpChannel.cxx | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/panda/src/downloader/config_downloader.cxx b/panda/src/downloader/config_downloader.cxx index f3cecfa3a5..ed59500e29 100644 --- a/panda/src/downloader/config_downloader.cxx +++ b/panda/src/downloader/config_downloader.cxx @@ -23,16 +23,19 @@ ConfigureDef(config_downloader); NotifyCategoryDef(downloader, ""); -ConfigVariableInt downloader_disk_write_frequency -("downloader-disk-write-frequency", 4, - PRC_DESC("How often we write to disk is determined by this ratio which is " - "relative to the downloader-byte-rate (e.g. if disk-write-ratio is 4, " - "we will write every 4 seconds if the frequency is 0.2)")); - ConfigVariableInt downloader_byte_rate -("downloader-byte-rate", 3600, - PRC_DESC("We'd like this to be about 1 second worth of download assuming a " - "28.8Kb connection (28.8Kb / 8 = 3600 bytes per second).")); +("downloader-byte-rate", 500000, + PRC_DESC("Specifies the default max bytes per second of throughput that is " + "supported by any HTTP connections with download-throttle enabled. " + "This may also be set on a per-channel basis with " + "HTTPChannel::set_max_bytes_per_second(). It has no effect unless " + "download-throttle (or HTTPChannel::set_download_throttle) is true.")); + +ConfigVariableBool download_throttle +("download-throttle", false, + PRC_DESC("When this is true, all HTTP channels will be bandwidth-limited " + "so as not to consume more than downloader-byte-rate bytes per " + "second.")); ConfigVariableDouble downloader_frequency ("downloader-frequency", 0.2, diff --git a/panda/src/downloader/config_downloader.h b/panda/src/downloader/config_downloader.h index fec0bef24a..374ba2252a 100644 --- a/panda/src/downloader/config_downloader.h +++ b/panda/src/downloader/config_downloader.h @@ -28,8 +28,8 @@ ConfigureDecl(config_downloader, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(downloader, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); -extern ConfigVariableInt downloader_disk_write_frequency; extern ConfigVariableInt downloader_byte_rate; +extern ConfigVariableBool download_throttle; extern ConfigVariableDouble downloader_frequency; extern ConfigVariableInt downloader_timeout; extern ConfigVariableInt downloader_timeout_retries; diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 813ea1475d..f49da3b260 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -53,7 +53,7 @@ HTTPChannel(HTTPClient *client) : _skip_body_size = http_skip_body_size; _idle_timeout = http_idle_timeout; _blocking_connect = false; - _download_throttle = false; + _download_throttle = download_throttle; _max_bytes_per_second = downloader_byte_rate; _seconds_per_update = downloader_frequency; _max_updates_per_second = 1.0f / _seconds_per_update;