fixed the issue with the timer waiting for tracker requests when quitting, reported by Tianhao Qiu

This commit is contained in:
Arvid Norberg 2006-07-12 22:55:06 +00:00
parent 4403eac97b
commit 8c6869b4f2
4 changed files with 22 additions and 21 deletions

View File

@ -18,7 +18,7 @@
<tr><th class="docinfo-name">Author:</th>
<td>Arvid Norberg, <a class="last reference" href="mailto:arvid&#64;rasterbar.com">arvid&#64;rasterbar.com</a></td></tr>
<tr><th class="docinfo-name">Version:</th>
<td>0.9.2</td></tr>
<td>0.10</td></tr>
</tbody>
</table>
<div class="contents topic" id="table-of-contents">

View File

@ -3,7 +3,7 @@ libtorrent manual
=================
:Author: Arvid Norberg, arvid@rasterbar.com
:Version: 0.9.2
:Version: 0.10
.. contents:: Table of contents
:depth: 2

View File

@ -212,7 +212,7 @@ namespace libtorrent
assert(m_open_mode & mode_out);
assert(m_fd != -1);
// Test this a bit more, what happens with random failures in
// TODO: Test this a bit more, what happens with random failures in
// the files?
// if ((rand() % 100) > 80)
// throw file_error("debug");

View File

@ -966,32 +966,33 @@ namespace libtorrent { namespace detail
assert(false);
}
{
session_impl::mutex_t::scoped_lock l(m_mutex);
deadline_timer tracker_timer(m_selector);
m_tracker_manager.abort_all_requests();
for (std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator i =
m_torrents.begin(); i != m_torrents.end(); ++i)
session_impl::mutex_t::scoped_lock l(m_mutex);
m_tracker_manager.abort_all_requests();
for (std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator i =
m_torrents.begin(); i != m_torrents.end(); ++i)
{
i->second->abort();
if (!i->second->is_paused() || i->second->should_request())
{
i->second->abort();
if (!i->second->is_paused() || i->second->should_request())
{
tracker_request req = i->second->generate_tracker_request();
req.listen_port = m_listen_interface.port();
req.key = m_key;
std::string login = i->second->tracker_login();
m_tracker_manager.queue_request(m_selector, req, login);
}
tracker_request req = i->second->generate_tracker_request();
req.listen_port = m_listen_interface.port();
req.key = m_key;
std::string login = i->second->tracker_login();
m_tracker_manager.queue_request(m_selector, req, login);
}
m_timer.expires_from_now(boost::posix_time::seconds(
m_settings.stop_tracker_timeout));
m_timer.async_wait(bind(&demuxer::interrupt, &m_selector));
}
tracker_timer.expires_from_now(boost::posix_time::seconds(
m_settings.stop_tracker_timeout));
tracker_timer.async_wait(bind(&demuxer::interrupt, &m_selector));
l.unlock();
m_selector.reset();
m_selector.run();
session_impl::mutex_t::scoped_lock l(m_mutex);
l.lock();
assert(m_abort);
m_abort = true;