From e5c2fc201ef3f70d8106ff5c31d69856bcbf6044 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 23 Oct 2002 19:14:45 +0000 Subject: [PATCH] fix throttling on slow machines --- panda/src/downloader/decompressor.cxx | 14 ++++++++++++++ panda/src/downloader/httpChannel.cxx | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index 59030741b2..ac3c34b4d2 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -116,6 +116,20 @@ initiate(const Filename &source_file, const Filename &dest_file) { ofstream *dest_fstream = new ofstream; _dest = dest_fstream; + if (dest_filename.exists()) { + downloader_cat.info() + << dest_filename << " already exists, removing.\n"; + if (!dest_filename.unlink()) { + downloader_cat.error() + << "Unable to remove old " << dest_filename << "\n"; + return get_write_error(); + } + } else { + if (downloader_cat.is_debug()) { + downloader_cat.debug() + << dest_filename << " does not already exist.\n"; + } + } if (!dest_filename.open_write(*dest_fstream)) { downloader_cat.error() << "Unable to write to " << dest_filename << "\n"; diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 73db528356..313518ac59 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -224,8 +224,15 @@ run() { // Come back later. return true; } + int num_potential_updates = (int)(elapsed / _seconds_per_update); _last_run_time = now; - _bytes_requested += _bytes_per_update; + _bytes_requested += _bytes_per_update * num_potential_updates; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "elapsed = " << elapsed << " num_potential_updates = " + << num_potential_updates << " bytes_requested = " + << _bytes_requested << "\n"; + } } switch (_download_dest) { case DD_none: @@ -568,6 +575,7 @@ reached_done_state() { return false; } else { _started_download = true; + _last_run_time = ClockObject::get_global_clock()->get_real_time(); return true; } }