fixed crash bug occuring when removing a torrent while it announces on the DHT. Fixed the mainloop not to quit when an uncought exception is thrown.
This commit is contained in:
parent
d5a421f78d
commit
d0a38c50c6
|
@ -495,6 +495,8 @@ namespace libtorrent
|
|||
tcp::resolver m_host_resolver;
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
static void on_dht_announce_response_disp(boost::weak_ptr<torrent> t
|
||||
, std::vector<tcp::endpoint> const& peers);
|
||||
deadline_timer m_dht_announce_timer;
|
||||
void on_dht_announce(asio::error const& e);
|
||||
void on_dht_announce_response(std::vector<tcp::endpoint> const& peers);
|
||||
|
|
|
@ -118,7 +118,6 @@ void closest_nodes::invoke(node_id const& id, udp::endpoint addr)
|
|||
|
||||
void closest_nodes::done()
|
||||
{
|
||||
std::cerr << "[closest_nodes] DONE" << std::endl;
|
||||
std::vector<node_entry> results;
|
||||
int result_size = m_table.bucket_size();
|
||||
if (result_size > (int)m_results.size()) result_size = (int)m_results.size();
|
||||
|
|
|
@ -948,21 +948,23 @@ namespace libtorrent { namespace detail
|
|||
|
||||
boost::posix_time::ptime timer = second_clock::universal_time();
|
||||
|
||||
// for(;;)
|
||||
// {
|
||||
try
|
||||
do
|
||||
{
|
||||
m_selector.run();
|
||||
assert(m_abort == true);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
std::cerr << e.what() << "\n";
|
||||
std::string err = e.what();
|
||||
#endif
|
||||
assert(false);
|
||||
try
|
||||
{
|
||||
m_selector.run();
|
||||
assert(m_abort == true);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
std::cerr << e.what() << "\n";
|
||||
std::string err = e.what();
|
||||
#endif
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
while (!m_abort);
|
||||
|
||||
deadline_timer tracker_timer(m_selector);
|
||||
|
||||
|
|
|
@ -185,7 +185,6 @@ namespace
|
|||
|
||||
peer_id const& pid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace libtorrent
|
||||
|
@ -439,17 +438,26 @@ namespace libtorrent
|
|||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
||||
void torrent::on_dht_announce_response_disp(boost::weak_ptr<libtorrent::torrent> t
|
||||
, std::vector<tcp::endpoint> const& peers)
|
||||
{
|
||||
boost::shared_ptr<libtorrent::torrent> tor = t.lock();
|
||||
if (!tor) return;
|
||||
tor->on_dht_announce_response(peers);
|
||||
}
|
||||
|
||||
void torrent::on_dht_announce(asio::error const& e)
|
||||
{
|
||||
if (e) return;
|
||||
m_dht_announce_timer.expires_from_now(boost::posix_time::minutes(30));
|
||||
m_dht_announce_timer.async_wait(bind(&torrent::on_dht_announce, this, _1));
|
||||
if (!m_ses.m_dht) return;
|
||||
// TODO: BUG! This may invoke on_dht_announce() with an invalid this-pointer.
|
||||
// there has to be a way to abort an announce operation on the dht.
|
||||
// TODO: There should be a way to abort an announce operation on the dht.
|
||||
// when the torrent is destructed
|
||||
boost::weak_ptr<torrent> self(shared_from_this());
|
||||
m_ses.m_dht->announce(m_torrent_file.info_hash()
|
||||
, m_ses.m_listen_interface.port()
|
||||
, bind(&torrent::on_dht_announce_response, this, _1));
|
||||
, bind(&torrent::on_dht_announce_response_disp, self, _1));
|
||||
}
|
||||
|
||||
void torrent::on_dht_announce_response(std::vector<tcp::endpoint> const& peers)
|
||||
|
|
Loading…
Reference in New Issue