From 94d31cc681f6c136b6ad8e59a372d3feb9510bcb Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sat, 17 Sep 2005 01:31:30 +0000 Subject: [PATCH] * Fixed various memory leaks/errors. * Don't increment beyond end when incrementing a entry's completed counter. * Don't allow ChokeManager::try_unchoke to succeed when it has been less than 10 seconds since the last unchoke. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@562 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/curl_get.cc | 10 +++++----- src/core/curl_stack.cc | 6 +++--- src/core/poll_manager.cc | 7 +++++++ src/main.cc | 7 +++++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/core/curl_get.cc b/src/core/curl_get.cc index 0e49438e..27ba25f3 100644 --- a/src/core/curl_get.cc +++ b/src/core/curl_get.cc @@ -37,9 +37,9 @@ #include "config.h" #include +#include #include #include -#include #include "curl_get.h" #include "curl_stack.h" @@ -51,7 +51,7 @@ CurlGet::CurlGet(CurlStack* s) : m_stack(s) { if (m_stack == NULL) - throw torrent::client_error("Tried to create CurlGet without a valid CurlStack"); + throw std::logic_error("Tried to create CurlGet without a valid CurlStack"); } CurlGet::~CurlGet() { @@ -66,10 +66,10 @@ CurlGet::new_object(CurlStack* s) { void CurlGet::start() { if (is_busy()) - throw torrent::internal_error("Tried to call CurlGet::start on a busy object"); + throw std::logic_error("Tried to call CurlGet::start on a busy object"); if (m_stream == NULL) - throw torrent::internal_error("Tried to call CurlGet::start without a valid output stream"); + throw std::logic_error("Tried to call CurlGet::start without a valid output stream"); m_handle = curl_easy_init(); @@ -117,7 +117,7 @@ CurlGet::get_size_total() { void CurlGet::perform(CURLMsg* msg) { if (msg->msg != CURLMSG_DONE) - throw torrent::client_error("CurlGet::process got CURLMSG that isn't done"); + throw std::logic_error("CurlGet::process got CURLMSG that isn't done"); if (msg->data.result == CURLE_OK) m_signalDone.emit(); diff --git a/src/core/curl_stack.cc b/src/core/curl_stack.cc index 513a1741..c914d689 100644 --- a/src/core/curl_stack.cc +++ b/src/core/curl_stack.cc @@ -106,7 +106,7 @@ CurlStack::add_get(CurlGet* get) { CURLMcode code; if ((code = curl_multi_add_handle((CURLM*)m_handle, get->handle())) > 0) - throw torrent::local_error("curl_multi_add_handle \"" + std::string(curl_multi_strerror(code))); + throw std::logic_error("curl_multi_add_handle \"" + std::string(curl_multi_strerror(code))); m_size++; m_getList.push_back(get); @@ -118,12 +118,12 @@ CurlStack::add_get(CurlGet* get) { void CurlStack::remove_get(CurlGet* get) { if (curl_multi_remove_handle((CURLM*)m_handle, get->handle()) > 0) - throw torrent::local_error("Error calling curl_multi_remove_handle"); + throw std::logic_error("Error calling curl_multi_remove_handle"); CurlGetList::iterator itr = std::find(m_getList.begin(), m_getList.end(), get); if (itr == m_getList.end()) - throw torrent::client_error("Could not find CurlGet when calling CurlStack::remove"); + throw std::logic_error("Could not find CurlGet when calling CurlStack::remove"); m_size--; m_getList.erase(itr); diff --git a/src/core/poll_manager.cc b/src/core/poll_manager.cc index 55b8ddbc..48abf130 100644 --- a/src/core/poll_manager.cc +++ b/src/core/poll_manager.cc @@ -79,9 +79,16 @@ PollManager::PollManager(torrent::Poll* poll) : PollManager::~PollManager() { delete m_poll; + +#if defined USE_VARIABLE_FDSET + delete [] m_readSet; + delete [] m_writeSet; + delete [] m_errorSet; +#else delete m_readSet; delete m_writeSet; delete m_errorSet; +#endif } void diff --git a/src/main.cc b/src/main.cc index 3cb31093..134be79e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #ifdef USE_EXECINFO @@ -240,6 +241,12 @@ main(int argc, char** argv) { uiControl.cleanup(); + } catch (torrent::base_error& e) { + display::Canvas::cleanup(); + + std::cout << "Caught exception from libtorrent: \"" << e.what() << '"' << std::endl; + return -1; + } catch (std::exception& e) { display::Canvas::cleanup();