From 66bb95a26cc3a623cac67c821673be4eba8d3eb0 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 4 Jul 2006 22:48:43 +0000 Subject: [PATCH] * Select the proper encoding for a torrent's name so that multi-file torrents get the right root directory. * Properly clean up after catching a storage_error in EntryList::open(). * Added a funtion to torrent::Download for syncing chunks to disk, and made torrent::resume_save_progress(...) use it. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@736 e378c898-3ddf-0310-93e7-cc216c733640 --- rak/timer.h | 3 ++- src/control.h | 1 + src/core/curl_stack.cc | 13 ++++++------- src/main.cc | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rak/timer.h b/rak/timer.h index 06a3bbac..b190b300 100644 --- a/rak/timer.h +++ b/rak/timer.h @@ -57,7 +57,8 @@ class timer { timeval tval() const { return (timeval) { m_time / 1000000, m_time % 1000000}; } static timer current(); - static timer from_seconds(uint32_t seconds) { return rak::timer((uint64_t)seconds * 1000000); } + static timer from_seconds(uint32_t seconds) { return rak::timer((uint64_t)seconds * 1000000); } + static timer from_milliseconds(uint32_t seconds) { return rak::timer((uint64_t)seconds * 1000); } bool operator < (const timer& t) const { return m_time < t.m_time; } bool operator > (const timer& t) const { return m_time > t.m_time; } diff --git a/src/control.h b/src/control.h index 9ed723ed..8a737bd3 100644 --- a/src/control.h +++ b/src/control.h @@ -76,6 +76,7 @@ public: bool is_shutdown_completed() { return m_shutdownQuick && torrent::is_inactive(); } bool is_shutdown_received() { return m_shutdownReceived; } + bool is_shutdown_started() { return m_shutdownQuick; } void initialize(); void cleanup(); diff --git a/src/core/curl_stack.cc b/src/core/curl_stack.cc index f2921a07..04bd6d92 100644 --- a/src/core/curl_stack.cc +++ b/src/core/curl_stack.cc @@ -76,15 +76,14 @@ CurlStack::perform() { int t; do { - CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &t); + CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &t); - CurlGetList::iterator itr = std::find_if(m_getList.begin(), m_getList.end(), - rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle))); + CurlGetList::iterator itr = std::find_if(m_getList.begin(), m_getList.end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle))); - if (itr == m_getList.end()) - throw std::logic_error("Could not find CurlGet with the right easy_handle"); - - (*itr)->perform(msg); + if (itr == m_getList.end()) + throw std::logic_error("Could not find CurlGet with the right easy_handle"); + + (*itr)->perform(msg); } while (t); } diff --git a/src/main.cc b/src/main.cc index f24642e5..64a12b19 100644 --- a/src/main.cc +++ b/src/main.cc @@ -126,10 +126,10 @@ load_arg_torrents(Control* c, char** first, char** last) { } } -rak::timer -client_next_timeout() { +static inline rak::timer +client_next_timeout(Control* c) { if (taskScheduler.empty()) - return rak::timer::from_seconds(60); + return c->is_shutdown_started() ? rak::timer::from_milliseconds(100) : rak::timer::from_seconds(60); else if (taskScheduler.top()->time() <= cachedTime) return 0; else @@ -252,7 +252,7 @@ main(int argc, char** argv) { rak::priority_queue_perform(&taskScheduler, cachedTime); // Do shutdown check before poll, not after. - control->core()->get_poll_manager()->poll(client_next_timeout()); + control->core()->get_poll_manager()->poll(client_next_timeout(control)); } control->core()->download_list()->session_save();