diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index 77e9c4e49..880c22c16 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -312,10 +312,10 @@ namespace aux { // this is set when the piece should be evicted as soon as there // no longer are any references to it. Evicted here means demoted // to a ghost list - boost::uint32_t marked_for_eviction:1; + std::uint32_t marked_for_eviction:1; // the number of blocks that have >= 1 refcount - boost::uint32_t pinned:15; + std::uint32_t pinned:15; // ---- 32 bit boundary --- diff --git a/include/libtorrent/fwd.hpp b/include/libtorrent/fwd.hpp index 2b0277fdb..6a443fd36 100644 --- a/include/libtorrent/fwd.hpp +++ b/include/libtorrent/fwd.hpp @@ -134,8 +134,11 @@ struct picker_log_alert; struct session_error_alert; struct dht_live_nodes_alert; struct session_stats_header_alert; +struct dht_sample_infohashes_alert; +struct block_uploaded_alert; // include/libtorrent/announce_entry.hpp +struct announce_endpoint; struct announce_entry; // include/libtorrent/bdecode.hpp @@ -182,13 +185,6 @@ class hasher512; struct ip_filter; class port_filter; -// include/libtorrent/kademlia/dht_state.hpp -struct dht_state; - -// include/libtorrent/kademlia/dht_storage.hpp -struct dht_storage_counters; -struct dht_storage_interface; - // include/libtorrent/peer_connection_handle.hpp struct peer_connection_handle; struct bt_peer_connection_handle; @@ -241,11 +237,23 @@ class torrent_info; // include/libtorrent/torrent_status.hpp struct torrent_status; +namespace dht { + +// include/libtorrent/kademlia/dht_state.hpp +struct dht_state; + +// include/libtorrent/kademlia/dht_storage.hpp +struct dht_storage_counters; +struct dht_storage_interface; + +} + #ifndef TORRENT_NO_DEPRECATE // include/libtorrent/alert_types.hpp struct torrent_added_alert; struct mmap_cache_alert; +struct torrent_update_alert; // include/libtorrent/file_storage.hpp struct file_entry; diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 5f109406b..819949854 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -937,21 +937,21 @@ namespace libtorrent { DLOG("try_flush_write_blocks: %d\n", num); list_iterator range = m_disk_cache.write_lru_pieces(); - aux::vector> pieces; + aux::vector, piece_index_t>> pieces; pieces.reserve(m_disk_cache.num_write_lru_pieces()); for (list_iterator p = range; p.get() && num > 0; p.next()) { cached_piece_entry* e = p.get(); if (e->num_dirty == 0) continue; - pieces.push_back(std::make_pair(e->storage.get(), e->piece)); + pieces.push_back(std::make_pair(e->storage, e->piece)); } for (auto const& p : pieces) { // TODO: instead of doing a lookup each time through the loop, save // cached_piece_entry pointers with piece_refcount incremented to pin them - cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second); + cached_piece_entry* pe = m_disk_cache.find_piece(p.first.get(), p.second); if (pe == nullptr) continue; // another thread may flush this piece while we're looping and @@ -980,7 +980,7 @@ namespace libtorrent { // everything in LRU order (degrade to lru cache eviction) for (auto const& p : pieces) { - cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second); + cached_piece_entry* pe = m_disk_cache.find_piece(p.first.get(), p.second); if (pe == nullptr) continue; if (pe->num_dirty == 0) continue; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f1e9cb7dc..7bde8537a 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -4985,10 +4985,18 @@ namespace { void session_impl::update_outgoing_interfaces() { - std::string net_interfaces = m_settings.get_str(settings_pack::outgoing_interfaces); + std::string const net_interfaces = m_settings.get_str(settings_pack::outgoing_interfaces); // declared in string_util.hpp parse_comma_separated_string(net_interfaces, m_outgoing_interfaces); + +#ifndef TORRENT_DISABLE_LOGGING + if (!net_interfaces.empty() && m_outgoing_interfaces.empty()) + { + session_log("ERROR: failed to parse outgoing interface list: %s" + , net_interfaces.c_str()); + } +#endif } tcp::endpoint session_impl::bind_outgoing_socket(socket_type& s, address @@ -5229,6 +5237,11 @@ namespace { #ifndef TORRENT_DISABLE_LOGGING if (should_log()) { + if (!net_interfaces.empty() && m_listen_interfaces.empty()) + { + session_log("ERROR: failed to parse listen_interfaces setting: %s" + , net_interfaces.c_str()); + } session_log("update listen interfaces: %s", net_interfaces.c_str()); session_log("parsed listen interfaces count: %d, ifaces: %s" , int(m_listen_interfaces.size()) @@ -5334,6 +5347,12 @@ namespace { std::vector> nodes; parse_comma_separated_string_port(node_list, nodes); +#ifndef TORRENT_DISABLE_LOGGING + if (!node_list.empty() && nodes.empty()) + { + session_log("ERROR: failed to parse DHT bootstrap list: %s", node_list.c_str()); + } +#endif for (auto const& n : nodes) add_dht_router(n); #endif diff --git a/src/torrent.cpp b/src/torrent.cpp index e31810f61..e152a26df 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -837,6 +837,12 @@ namespace libtorrent { std::shared_ptr rp = std::make_shared(); rp->piece_data.reset(new (std::nothrow) char[piece_size]); + if (!rp->piece_data) + { + m_ses.alerts().emplace_alert( + get_handle(), piece, error_code(boost::system::errc::not_enough_memory, generic_category())); + return; + } rp->blocks_left = 0; rp->fail = false; diff --git a/tools/gen_fwd.py b/tools/gen_fwd.py index 8febe76e8..aeb0137f6 100644 --- a/tools/gen_fwd.py +++ b/tools/gen_fwd.py @@ -57,6 +57,7 @@ deprecated_classes = os.popen('git grep TORRENT_DEPRECATED_EXPORT').read().split def filter_classes(classes, keyword): current_file = '' ret = '' + dht_ret = '' for c in classes: line = c.split(':', 1) if not line[0].endswith('.hpp'): continue @@ -71,13 +72,22 @@ def filter_classes(classes, keyword): # TODO: support TORRENT_DEPRECATED_EXPORT if decl[1].strip() != keyword: continue + content = '' if this_file != current_file: - ret += '\n// ' + this_file + '\n' + content += '\n// ' + this_file + '\n' current_file = this_file; decl = decl[0] + ' ' + decl[2] if not decl.endswith(';'): decl += ';' - ret += decl + '\n' - return ret + content += decl + '\n' + if 'kademlia' in this_file: + dht_ret += content + else: + ret += content + + if dht_ret == '': + return ret + else: + return ret + '\nnamespace dht {\n' + dht_ret + '\n}\n' os.remove('include/libtorrent/fwd.hpp') with open('include/libtorrent/fwd.hpp', 'w+') as f: