clear alert nofify function when calling abort on a session, to avoid touching a destructed session object (#1015)
This commit is contained in:
parent
e247473b86
commit
b701fb252a
|
@ -281,7 +281,7 @@ namespace libtorrent
|
|||
// session_proxy();
|
||||
// ~session_proxy()
|
||||
// };
|
||||
session_proxy abort() { return session_proxy(m_io_service, m_thread, m_impl); }
|
||||
session_proxy abort();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ void run_test(Setup const& setup, Test const& test)
|
|||
test(*ses);
|
||||
|
||||
// shut down
|
||||
ses->set_alert_notify([]{});
|
||||
zombie = ses->abort();
|
||||
ses.reset();
|
||||
});
|
||||
|
|
|
@ -79,7 +79,6 @@ void run_fake_peer_test(
|
|||
sim::timer t(sim, lt::seconds(1)
|
||||
, [&](boost::system::error_code const& ec)
|
||||
{
|
||||
ses->set_alert_notify([]{});
|
||||
// shut down
|
||||
zombie = ses->abort();
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ void run_test(Setup const& setup
|
|||
{
|
||||
test(*ses, test_peers);
|
||||
|
||||
ses->set_alert_notify([]{});
|
||||
// shut down
|
||||
zombie = ses->abort();
|
||||
|
||||
|
|
|
@ -148,7 +148,6 @@ TORRENT_TEST(optimistic_unchoke)
|
|||
{
|
||||
p->abort();
|
||||
}
|
||||
ses->set_alert_notify([]{});
|
||||
proxy = ses->abort();
|
||||
ses.reset();
|
||||
});
|
||||
|
|
|
@ -101,7 +101,6 @@ void run_test(Setup const& setup
|
|||
{
|
||||
fprintf(stderr, "shutting down\n");
|
||||
// shut down
|
||||
ses->set_alert_notify([] {});
|
||||
zombie = ses->abort();
|
||||
ses.reset();
|
||||
});
|
||||
|
|
|
@ -352,7 +352,6 @@ TORRENT_TEST(ipv6_support)
|
|||
, [&ses,&zombie](boost::system::error_code const& ec)
|
||||
{
|
||||
zombie = ses->abort();
|
||||
ses->set_alert_notify([]{});
|
||||
ses.reset();
|
||||
});
|
||||
|
||||
|
@ -427,7 +426,6 @@ void tracker_test(Setup setup, Announce a, Test1 test1, Test2 test2
|
|||
, [&ses,&zombie](boost::system::error_code const& ec)
|
||||
{
|
||||
zombie = ses->abort();
|
||||
ses->set_alert_notify([]{});
|
||||
ses.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -139,7 +139,6 @@ void run_test(
|
|||
int idx = 0;
|
||||
for (auto& s : ses)
|
||||
{
|
||||
s->set_alert_notify([]{});
|
||||
zombie[idx++] = s->abort();
|
||||
s.reset();
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ void run_test(Setup const& setup
|
|||
{
|
||||
fprintf(stderr, "shutting down\n");
|
||||
// shut down
|
||||
ses->set_alert_notify([] {});
|
||||
zombie = ses->abort();
|
||||
ses.reset();
|
||||
});
|
||||
|
|
|
@ -409,6 +409,14 @@ namespace libtorrent
|
|||
m_thread->join();
|
||||
}
|
||||
|
||||
session_proxy session::abort()
|
||||
{
|
||||
// stop calling the alert notify function now, to avoid it thinking the
|
||||
// session is still alive
|
||||
m_impl->alerts().set_notify_function(boost::function<void()>());
|
||||
return session_proxy(m_io_service, m_thread, m_impl);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
session_settings::session_settings(std::string const& user_agent_)
|
||||
{
|
||||
|
|
|
@ -1076,6 +1076,10 @@ namespace aux {
|
|||
session_log(" *** ABORT CALLED ***");
|
||||
#endif
|
||||
|
||||
// at this point we cannot call the notify function anymore, since the
|
||||
// session will become invalid.
|
||||
m_alerts.set_notify_function(boost::function<void()>());
|
||||
|
||||
// this will cancel requests that are not critical for shutting down
|
||||
// cleanly. i.e. essentially tracker hostname lookups that we're not
|
||||
// about to send event=stopped to
|
||||
|
|
Loading…
Reference in New Issue