diff --git a/CMakeLists.txt b/CMakeLists.txt index 547f25e6d..de5604922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,7 @@ set(sources torrent_info torrent_peer torrent_peer_allocator + torrent_status tracker_manager http_tracker_connection utf8 diff --git a/Jamfile b/Jamfile index e29f87d29..0adee55bf 100644 --- a/Jamfile +++ b/Jamfile @@ -624,6 +624,7 @@ SOURCES = torrent_info torrent_peer torrent_peer_allocator + torrent_status time tracker_manager http_tracker_connection diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index b48c5e02c..c1049e234 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -207,7 +207,7 @@ private: // maximum size of bottled buffer int m_max_bottled_buffer_size; - + // the current download limit, in bytes per second // 0 is unlimited. int m_rate_limit; diff --git a/src/Makefile.am b/src/Makefile.am index e47481878..8e8bafc74 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -130,6 +130,7 @@ libtorrent_rasterbar_la_SOURCES = \ torrent_info.cpp \ torrent_peer.cpp \ torrent_peer_allocator.cpp \ + torrent_status.cpp \ time.cpp \ timestamp_history.cpp \ tracker_manager.cpp \ diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 2c0ba7d06..bd5cd4cbc 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -1734,7 +1734,6 @@ void block_cache::check_invariant() const TORRENT_PIECE_ASSERT(!p.blocks[k].pending, &p); TORRENT_PIECE_ASSERT(p.blocks[k].refcount == 0, &p); } - TORRENT_PIECE_ASSERT(p.blocks[k].refcount >= 0, &p); num_refcount += p.blocks[k].refcount; } TORRENT_PIECE_ASSERT(num_blocks == p.num_blocks, &p); diff --git a/src/http_connection.cpp b/src/http_connection.cpp index bcf4f5521..8f2f9eb70 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -81,6 +81,8 @@ http_connection::http_connection(io_service& ios , m_connect_handler(ch) , m_filter_handler(fh) , m_timer(ios) + , m_read_timeout(seconds(5)) + , m_completion_timeout(seconds(5)) , m_limiter_timer(ios) , m_last_receive(aux::time_now()) , m_start_time(aux::time_now()) diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index d845e3b70..694553580 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -3326,7 +3326,6 @@ get_out: info.peer = peer; if (info.state == block_info::state_requested) --i->requested; - TORRENT_ASSERT(i->requested >= 0); if (info.state == block_info::state_writing || info.state == block_info::state_finished) return false; @@ -3486,7 +3485,6 @@ get_out: info.peer = peer; TORRENT_ASSERT(info.state == block_info::state_writing || peer == 0); - TORRENT_ASSERT(i->writing >= 0); if (info.state == block_info::state_writing) { --i->writing; diff --git a/src/torrent.cpp b/src/torrent.cpp index aca196ab8..4f26edb32 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1164,8 +1164,6 @@ namespace libtorrent , resolve_filename(j->error.file).c_str()); #endif - TORRENT_ASSERT(j->piece >= 0); - if (j->action == disk_io_job::write) { piece_block block_finished(j->piece, j->d.io.offset / block_size()); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 33feaa2e5..0e72528fd 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -143,77 +143,6 @@ using libtorrent::aux::session_impl; namespace libtorrent { - torrent_status::torrent_status() - : error_file(torrent_status::error_file_none) - , total_download(0) - , total_upload(0) - , total_payload_download(0) - , total_payload_upload(0) - , total_failed_bytes(0) - , total_redundant_bytes(0) - , total_done(0) - , total_wanted_done(0) - , total_wanted(0) - , all_time_upload(0) - , all_time_download(0) - , added_time(0) - , completed_time(0) - , last_seen_complete(0) - , storage_mode(storage_mode_sparse) - , progress(0.f) - , progress_ppm(0) - , queue_position(0) - , download_rate(0) - , upload_rate(0) - , download_payload_rate(0) - , upload_payload_rate(0) - , num_seeds(0) - , num_peers(0) - , num_complete(-1) - , num_incomplete(-1) - , list_seeds(0) - , list_peers(0) - , connect_candidates(0) - , num_pieces(0) - , distributed_full_copies(0) - , distributed_fraction(0) - , distributed_copies(0.f) - , block_size(0) - , num_uploads(0) - , num_connections(0) - , uploads_limit(0) - , connections_limit(0) - , up_bandwidth_queue(0) - , down_bandwidth_queue(0) - , time_since_upload(0) - , time_since_download(0) - , active_time(0) - , finished_time(0) - , seeding_time(0) - , seed_rank(0) - , last_scrape(0) - , priority(0) - , state(checking_resume_data) - , need_save_resume(false) - , ip_filter_applies(true) - , upload_mode(false) - , share_mode(false) - , super_seeding(false) - , paused(false) - , auto_managed(false) - , sequential_download(false) - , is_seeding(false) - , is_finished(false) - , has_metadata(false) - , has_incoming(false) - , seed_mode(false) - , moving_storage(false) - , is_loaded(true) - , info_hash(0) - {} - - torrent_status::~torrent_status() {} - #ifndef BOOST_NO_EXCEPTIONS void throw_invalid_handle() { diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 594ad73ce..14034b1b5 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -376,7 +376,6 @@ namespace libtorrent --added; TORRENT_ASSERT(added >= 0); } -#endif if (added == 0 && added_separator) { @@ -384,6 +383,7 @@ namespace libtorrent path.erase(path.end()-1); return; } +#endif if (path.empty()) path = "_"; } @@ -1346,7 +1346,7 @@ namespace libtorrent error_code ec; bdecode(m_info_section.get(), m_info_section.get() + m_info_section_size, m_info_dict, ec); - if (ec) return bdecode_node(); + if (ec) return bdecode_node(); } return m_info_dict.dict_find(key); } diff --git a/src/torrent_status.cpp b/src/torrent_status.cpp new file mode 100644 index 000000000..c04454b68 --- /dev/null +++ b/src/torrent_status.cpp @@ -0,0 +1,114 @@ +/* + +Copyright (c) 2015-2016, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "libtorrent/torrent_status.hpp" + +namespace libtorrent +{ + torrent_status::torrent_status() + : error_file(torrent_status::error_file_none) + , next_announce(seconds(0)) + , total_download(0) + , total_upload(0) + , total_payload_download(0) + , total_payload_upload(0) + , total_failed_bytes(0) + , total_redundant_bytes(0) + , total_done(0) + , total_wanted_done(0) + , total_wanted(0) + , all_time_upload(0) + , all_time_download(0) + , added_time(0) + , completed_time(0) + , last_seen_complete(0) + , storage_mode(storage_mode_sparse) + , progress(0.f) + , progress_ppm(0) + , queue_position(0) + , download_rate(0) + , upload_rate(0) + , download_payload_rate(0) + , upload_payload_rate(0) + , num_seeds(0) + , num_peers(0) + , num_complete(-1) + , num_incomplete(-1) + , list_seeds(0) + , list_peers(0) + , connect_candidates(0) + , num_pieces(0) + , distributed_full_copies(0) + , distributed_fraction(0) + , distributed_copies(0.f) + , block_size(0) + , num_uploads(0) + , num_connections(0) + , uploads_limit(0) + , connections_limit(0) + , up_bandwidth_queue(0) + , down_bandwidth_queue(0) + , time_since_upload(0) + , time_since_download(0) + , active_time(0) + , finished_time(0) + , seeding_time(0) + , seed_rank(0) + , last_scrape(0) + , priority(0) + , state(checking_resume_data) + , need_save_resume(false) + , ip_filter_applies(true) + , upload_mode(false) + , share_mode(false) + , super_seeding(false) + , paused(false) + , auto_managed(false) + , sequential_download(false) + , is_seeding(false) + , is_finished(false) + , has_metadata(false) + , has_incoming(false) + , seed_mode(false) + , moving_storage(false) + , is_loaded(true) + , announcing_to_trackers(false) + , announcing_to_lsd(false) + , announcing_to_dht(false) + , stop_when_ready(false) + , info_hash(0) + {} + + torrent_status::~torrent_status() {} + +} +