fix crash on exit
This commit is contained in:
parent
3ed1de43c2
commit
2949ab545d
|
@ -568,15 +568,24 @@ namespace libtorrent
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
tracker_connections_t keep_connections;
|
tracker_connections_t keep_connections;
|
||||||
|
|
||||||
for (tracker_connections_t::const_iterator i =
|
while (!m_connections.empty())
|
||||||
m_connections.begin(); i != m_connections.end(); ++i)
|
|
||||||
{
|
{
|
||||||
if (!*i) continue;
|
boost::intrusive_ptr<tracker_connection>& c = m_connections.back();
|
||||||
tracker_request const& req = (*i)->tracker_req();
|
if (!c)
|
||||||
|
{
|
||||||
|
m_connections.pop_back();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tracker_request const& req = c->tracker_req();
|
||||||
if (req.event == tracker_request::stopped)
|
if (req.event == tracker_request::stopped)
|
||||||
keep_connections.push_back(*i);
|
{
|
||||||
else
|
keep_connections.push_back(c);
|
||||||
(*i)->close();
|
m_connections.pop_back();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// close will remove the entry from m_connections
|
||||||
|
// so no need to pop
|
||||||
|
c->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::swap(m_connections, keep_connections);
|
std::swap(m_connections, keep_connections);
|
||||||
|
|
Loading…
Reference in New Issue