fix issue where event=stopped announces wouldn't be sent when closing session

This commit is contained in:
Arvid Norberg
2011-09-17 21:15:42 +00:00
parent 52a0760e5b
commit 4e1af65fe0
8 changed files with 91 additions and 4 deletions

View File

@@ -75,7 +75,7 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(priority >= 0);
TORRENT_ASSERT(priority < 2);
TORRENT_ASSERT(priority < 3);
entry* e = 0;
@@ -86,6 +86,7 @@ namespace libtorrent
e = &m_queue.back();
break;
case 1:
case 2:
m_queue.push_front(entry());
e = &m_queue.front();
break;
@@ -133,12 +134,18 @@ namespace libtorrent
m_timer.cancel(ec);
m_abort = true;
std::list<entry> to_keep;
while (!m_queue.empty())
{
// we don't want to call the timeout callback while we're locked
// since that is a recipie for dead-locks
entry e = m_queue.front();
m_queue.pop_front();
if (e.priority > 1)
{
to_keep.push_back(e);
continue;
}
if (e.connecting) --m_num_connecting;
l.unlock();
TORRENT_TRY {
@@ -146,6 +153,8 @@ namespace libtorrent
} TORRENT_CATCH(std::exception&) {}
l.lock();
}
m_queue.swap(to_keep);
}
void connection_queue::limit(int limit)