From 81289c9354d98bb071520570be54ecd0a823fad7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 6 Nov 2003 10:44:19 +0000 Subject: [PATCH] *** empty log message *** --- examples/client_test.cpp | 8 +++----- include/libtorrent/session.hpp | 2 +- include/libtorrent/torrent.hpp | 4 ++-- src/torrent.cpp | 5 ++--- src/torrent_handle.cpp | 9 +++++++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index c0a7e31a3..06cb821cc 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -149,7 +149,7 @@ int main(int argc, char* argv[]) if (argc < 2) { std::cerr << "usage: ./client_test torrent-files ...\n" - "to stop the client, type a number and press enter.\n"; + "to stop the client, press q.\n"; return 1; } @@ -222,8 +222,8 @@ int main(int argc, char* argv[]) i->get_peer_info(peers); float down = 0.f; float up = 0.f; - unsigned int total_down = 0; - unsigned int total_up = 0; + unsigned int total_down = s.total_download; + unsigned int total_up = s.total_upload; int num_peers = peers.size(); for (std::vector::iterator i = peers.begin(); @@ -232,8 +232,6 @@ int main(int argc, char* argv[]) { down += i->down_speed; up += i->up_speed; - total_down += i->total_download; - total_up += i->total_upload; } /* std::cout << boost::format("%f%% p:%d d:(%s) %s/s u:(%s) %s/s\n") diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index e142b4f3b..99042a9d6 100755 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -85,7 +85,7 @@ namespace libtorrent // workaround for microsofts // hardware exceptions that makes // it hard to debug stuff -#if defined(WIN32) && !defined(NDEBUG) +#if defined(_MSC_VER) && !defined(NDEBUG) struct eh_initializer { eh_initializer() diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 14a5e3b32..e455e1b63 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -249,8 +249,8 @@ namespace libtorrent void parse_response(const entry& e, std::vector& peer_list); - // total amount of bytes uploaded, downloaded and - // the number of bytes left to be downloaded + // TODO: Replace with stat-object + // total amount of bytes uploaded, downloaded entry::integer_type m_bytes_uploaded; entry::integer_type m_bytes_downloaded; diff --git a/src/torrent.cpp b/src/torrent.cpp index 49dda7920..480c5e600 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -422,9 +422,8 @@ namespace libtorrent - blocks_per_piece; } - // TODO: Implement total download and total_upload - st.total_download = 0; - st.total_upload = 0; + st.total_download = m_bytes_downloaded; + st.total_upload = m_bytes_uploaded; st.progress = (blocks_we_have + unverified_blocks) / static_cast(total_blocks); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index da2aa218f..9ea8c0b2b 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -69,13 +69,14 @@ namespace libtorrent { torrent_status st; st.total_download = 0; - st.total_download = 0; + st.total_upload = 0; st.progress = 0.f; st.state = torrent_status::invalid_handle; st.next_announce = boost::posix_time::time_duration(); return st; } + assert(m_chk != 0); { boost::mutex::scoped_lock l(m_ses->m_mutex); torrent* t = m_ses->find_torrent(m_info_hash); @@ -103,7 +104,7 @@ namespace libtorrent torrent_status st; st.total_download = 0; - st.total_download = 0; + st.total_upload = 0; st.progress = 0.f; st.state = torrent_status::invalid_handle; st.next_announce = boost::posix_time::time_duration(); @@ -114,6 +115,8 @@ namespace libtorrent { v.clear(); if (m_ses == 0) return; + assert(m_chk != 0); + boost::mutex::scoped_lock l(m_ses->m_mutex); const torrent* t = m_ses->find_torrent(m_info_hash); @@ -151,6 +154,7 @@ namespace libtorrent queue.clear(); if (m_ses == 0) return; + assert(m_chk != 0); boost::mutex::scoped_lock l(m_ses->m_mutex); torrent* t = m_ses->find_torrent(m_info_hash); @@ -183,6 +187,7 @@ namespace libtorrent void torrent_handle::abort() { if (m_ses == 0) return; + assert(m_chk != 0); { boost::mutex::scoped_lock l(m_ses->m_mutex);