From 14475fd4c1201a1396acd5c63d85bebbbbb12874 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 21 Mar 2006 20:37:00 +0000 Subject: [PATCH] * Moved Listen to ConnectionManager and use a single port rather than cache it in each download. * Set classic locale on various streams. * Added ChunkStatistic class that will keep track of the number of each chunk, and how many seeders there are. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@654 e378c898-3ddf-0310-93e7-cc216c733640 --- src/control.cc | 3 ++- src/core/curl_get.cc | 2 +- src/core/manager.cc | 12 +++++------- src/display/utils.cc | 2 +- src/display/window_download_statusbar.cc | 3 ++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/control.cc b/src/control.cc index 47bb5b53..f660f0ef 100644 --- a/src/control.cc +++ b/src/control.cc @@ -37,6 +37,7 @@ #include "config.h" #include +#include #include "core/manager.h" #include "display/canvas.h" @@ -129,7 +130,7 @@ Control::cleanup() { void Control::handle_shutdown() { if (!m_shutdownQuick) { - torrent::listen_close(); + torrent::connection_manager()->listen_close(); m_core->shutdown(false); if (!m_taskShutdown.is_queued()) diff --git a/src/core/curl_get.cc b/src/core/curl_get.cc index e4539b70..6d1465ba 100644 --- a/src/core/curl_get.cc +++ b/src/core/curl_get.cc @@ -48,7 +48,7 @@ namespace core { size_t curl_get_receive_write(void* data, size_t size, size_t nmemb, void* handle) { - if (!((CurlGet*)handle)->stream()->write((char*)data, size * nmemb).fail()) + if (!((CurlGet*)handle)->stream()->write((const char*)data, size * nmemb).fail()) return size * nmemb; else return 0; diff --git a/src/core/manager.cc b/src/core/manager.cc index e0b8f437..239127a9 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -39,8 +39,6 @@ #include #include #include -#include -#include #include #include #include @@ -201,12 +199,12 @@ Manager::listen_open() { if (control->variables()->get("port_random").as_string() == "yes") { int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1); - if (!torrent::listen_open(boundary, m_portLast) && - !torrent::listen_open(m_portFirst, boundary)) + if (!torrent::connection_manager()->listen_open(boundary, m_portLast) && + !torrent::connection_manager()->listen_open(m_portFirst, boundary)) throw torrent::input_error("Could not open/bind a port for listening."); } else { - if (!torrent::listen_open(m_portFirst, m_portLast)) + if (!torrent::connection_manager()->listen_open(m_portFirst, m_portLast)) throw torrent::input_error("Could not open/bind a port for listening."); } @@ -222,8 +220,8 @@ Manager::set_bind_address(const std::string& addr) { try { - if (torrent::listen_port() != 0) { - torrent::listen_close(); + if (torrent::connection_manager()->listen_port() != 0) { + torrent::connection_manager()->listen_close(); torrent::connection_manager()->set_bind_address(ai->address()->c_sockaddr()); listen_open(); diff --git a/src/display/utils.cc b/src/display/utils.cc index 7820a3f0..e176cbc2 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -213,7 +213,7 @@ print_status_info(char* first, char* last) { (double)torrent::up_rate()->rate() / 1024.0, (double)torrent::down_rate()->rate() / 1024.0); - first = print_buffer(first, last, " [Port: %i]", (unsigned int)torrent::listen_port()); + first = print_buffer(first, last, " [Port: %i]", (unsigned int)torrent::connection_manager()->listen_port()); if (!rak::socket_address::cast_from(torrent::connection_manager()->local_address())->is_address_any()) { first = print_buffer(first, last, " [Local "); diff --git a/src/display/window_download_statusbar.cc b/src/display/window_download_statusbar.cc index 866bb99d..93f2ae68 100644 --- a/src/display/window_download_statusbar.cc +++ b/src/display/window_download_statusbar.cc @@ -65,7 +65,7 @@ WindowDownloadStatusbar::redraw() { position = print_download_info(buffer, last, m_download); m_canvas->print(0, 0, "%s", buffer); - position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I: %i/%i Failed: %i", + position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C: %i/%i/%i Failed: %i", (int)m_download->get_download().peers_connected(), (int)m_download->get_download().peers_not_connected(), (int)m_download->get_download().peers_min(), @@ -73,6 +73,7 @@ WindowDownloadStatusbar::redraw() { (int)m_download->get_download().uploads_max(), (int)m_download->get_download().peers_currently_unchoked(), (int)m_download->get_download().peers_currently_interested(), + (int)m_download->get_download().peers_complete(), (int)m_download->chunks_failed()), 0); // position = buffer + std::max(snprintf(position, last - buffer, " Priority: %s",