diff --git a/docs/manual.rst b/docs/manual.rst index c38df951b..565b2ba78 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1038,7 +1038,7 @@ The ``torrent_info`` has the following synopsis:: std::vector const& url_seeds() const; size_type total_size() const; - size_type piece_length() const; + int piece_length() const; int num_pieces() const; sha1_hash const& info_hash() const; std::string const& name() const; @@ -1053,7 +1053,7 @@ The ``torrent_info`` has the following synopsis:: void print(std::ostream& os) const; - size_type piece_size(unsigned int index) const; + int piece_size(unsigned int index) const; sha1_hash const& hash_for_piece(unsigned int index) const; }; @@ -1370,8 +1370,8 @@ total_size() piece_length() piece_size() num_pieces() :: size_type total_size() const; - size_type piece_length() const; - size_type piece_size(unsigned int index) const; + int piece_length() const; + int piece_size(unsigned int index) const; int num_pieces() const; diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index dfacd8cb9..fd7904493 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -139,6 +139,8 @@ struct bandwidth_manager void close() { m_abort = true; + m_queue.clear(); + m_history.clear(); m_history_timer.cancel(); } @@ -192,6 +194,7 @@ struct bandwidth_manager { mutex_t::scoped_lock l(m_mutex); INVARIANT_CHECK; + if (m_abort) return; TORRENT_ASSERT(blk > 0); TORRENT_ASSERT(!is_queued(peer.get(), l)); TORRENT_ASSERT(!peer->ignore_bandwidth_limits()); diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index 0a6e5af54..758433296 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -57,7 +57,7 @@ namespace libtorrent { struct http_connection; -struct connection_queue; +class connection_queue; typedef boost::function http_handler; diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 42db8b7b1..4a520300b 100755 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -198,7 +198,7 @@ namespace libtorrent const std::vector& trackers() const { return m_urls; } size_type total_size() const { TORRENT_ASSERT(m_piece_length > 0); return m_total_size; } - size_type piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; } + int piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; } int num_pieces() const { TORRENT_ASSERT(m_piece_length > 0); return m_num_pieces; } const sha1_hash& info_hash() const { return m_info_hash; } const std::string& name() const { TORRENT_ASSERT(m_piece_length > 0); return m_name; } @@ -215,7 +215,7 @@ namespace libtorrent void convert_file_names(); - size_type piece_size(int index) const; + int piece_size(int index) const; const sha1_hash& hash_for_piece(int index) const { @@ -267,7 +267,7 @@ namespace libtorrent // the length of one piece // if this is 0, the torrent_info is // in an uninitialized state - size_type m_piece_length; + int m_piece_length; // the sha-1 hashes of each piece std::vector m_piece_hash; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 3db6e39eb..5e70b181c 100755 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -1265,7 +1265,7 @@ namespace libtorrent if (listen_port->type() == entry::int_t && peer_info_struct() != 0) { - t->get_policy().update_peer_port(listen_port->integer() + t->get_policy().update_peer_port(int(listen_port->integer()) , peer_info_struct(), peer_info::incoming); } } @@ -1281,7 +1281,7 @@ namespace libtorrent if (entry* reqq = root.find_key("reqq")) { if (reqq->type() == entry::int_t) - m_max_out_request_queue = reqq->integer(); + m_max_out_request_queue = int(reqq->integer()); if (m_max_out_request_queue < 1) m_max_out_request_queue = 1; } diff --git a/src/file_win.cpp b/src/file_win.cpp index 8e78dab3a..fb4f0ce9a 100644 --- a/src/file_win.cpp +++ b/src/file_win.cpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include namespace { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 3d3392b6a..afc74ab6a 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -630,6 +630,8 @@ namespace detail if (m_dht) m_dht->stop(); m_dht_socket.close(); #endif + m_download_channel.close(); + m_upload_channel.close(); m_timer.cancel(); // close the listen sockets diff --git a/src/storage.cpp b/src/storage.cpp index 7702d86e4..89df4a4d3 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -592,7 +592,7 @@ namespace libtorrent || pair.back().type() != entry::int_t) break; file_sizes.push_back(std::pair( - pair.front().integer(), pair.back().integer())); + pair.front().integer(), std::time_t(pair.back().integer()))); } if (file_sizes.empty()) @@ -1905,8 +1905,8 @@ namespace libtorrent num_pieces = 0; } - m_piece_data.resize(int(m_info->piece_length())); - int piece_size = int(m_info->piece_size(m_current_slot)); + m_piece_data.resize(m_info->piece_length()); + int piece_size = m_info->piece_size(m_current_slot); int num_read = m_storage->read(&m_piece_data[0] , m_current_slot, 0, piece_size); @@ -2010,7 +2010,7 @@ namespace libtorrent bool ret = false; if (piece_index >= 0) { - ret |= m_piece_to_slot[piece_index] = other_slot; + m_piece_to_slot[piece_index] = other_slot; ret |= m_storage->swap_slots(other_slot, m_current_slot); } else diff --git a/src/torrent.cpp b/src/torrent.cpp index 961f5ad7e..7f56a2ab8 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3126,8 +3126,8 @@ namespace libtorrent size_type done = 0; while (size > 0) { - size_type bytes_step = (std::min)(m_torrent_file->piece_size(ret.piece) - - ret.start, size); + size_type bytes_step = (std::min)(size_type(m_torrent_file->piece_size(ret.piece) + - ret.start), size); if (m_have_pieces[ret.piece]) done += bytes_step; ++ret.piece; ret.start = 0; diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index d3c72ca70..a184973f6 100755 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -886,13 +886,13 @@ namespace libtorrent // ------- end deprecation ------- - size_type torrent_info::piece_size(int index) const + int torrent_info::piece_size(int index) const { TORRENT_ASSERT(index >= 0 && index < num_pieces()); if (index == num_pieces()-1) { - size_type size = total_size() - - (num_pieces() - 1) * piece_length(); + int size = int(total_size() + - (num_pieces() - 1) * piece_length()); TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size <= piece_length()); return size; diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index e859435c0..04ee0a410 100755 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -474,7 +474,7 @@ namespace libtorrent // we should not try this server again. t->remove_url_seed(m_url); std::stringstream msg; - msg << "invalid range in HTTP response: " << range_str; + msg << "invalid range in HTTP response: " << range_str.str(); disconnect(msg.str().c_str()); return; } @@ -507,7 +507,7 @@ namespace libtorrent int file_index = m_file_requests.front(); peer_request in_range = info.map_file(file_index, range_start - , range_end - range_start); + , int(range_end - range_start)); peer_request front_request = m_requests.front(); diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 9693e6442..147f548d2 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -316,7 +316,7 @@ int test_main() int dist = distance_exp(a, b); TEST_CHECK(dist >= 0 && dist < 160); - TEST_CHECK(dist == ((i == j)?0:std::max(i, j))); + TEST_CHECK(dist == ((i == j)?0:(std::max)(i, j))); for (int k = 0; k < 160; k += 4) {