more dht fixes. polished client test output some

This commit is contained in:
Arvid Norberg 2007-03-02 05:02:12 +00:00
parent 83c2039ff7
commit 8f1128f540
2 changed files with 14 additions and 10 deletions

View File

@ -839,7 +839,7 @@ int main(int ac, char* av[])
++i;
}
out << "* " << esc("37") << std::setw(40)
out << "- " << esc("37") << std::setw(40)
<< std::setiosflags(std::ios::left);
if (h.has_metadata())
{
@ -888,11 +888,11 @@ int main(int ac, char* av[])
out << (s.progress*100) << "% ";
out << progress_bar(s.progress, 49, progress_bar_color);
out << "\n";
out << "total downloaded: " << esc("32") << s.total_done << esc("0") << " Bytes ";
out << " total downloaded: " << esc("32") << s.total_done << esc("0") << " Bytes ";
out << "peers: " << s.num_peers << " "
<< "seeds: " << s.num_seeds << " "
<< "distributed copies: " << s.distributed_copies << "\n"
<< "download: " << esc("32") << add_suffix(s.download_rate) << "/s " << esc("0")
<< " download: " << esc("32") << add_suffix(s.download_rate) << "/s " << esc("0")
<< "(" << esc("32") << add_suffix(s.total_download) << esc("0") << ") ";
}
else
@ -905,7 +905,7 @@ int main(int ac, char* av[])
if (s.state != torrent_status::seeding)
{
boost::posix_time::time_duration t = s.next_announce;
out << "next announce: " << esc("37") <<
out << " next announce: " << esc("37") <<
boost::posix_time::to_simple_string(t) << esc("0") << " ";
out << "tracker: " << s.current_tracker << "\n";
}

View File

@ -1520,6 +1520,7 @@ namespace libtorrent { namespace detail
void session_impl::stop_dht()
{
mutex_t::scoped_lock l(m_mutex);
if (!m_dht) return;
m_dht->stop();
m_dht = 0;
}
@ -1575,12 +1576,15 @@ namespace libtorrent { namespace detail
session_impl::~session_impl()
{
{
// lock the main thread and abort it
mutex_t::scoped_lock l(m_mutex);
m_abort = true;
m_io_service.stop();
}
#ifndef TORRENT_DISABLE_DHT
stop_dht();
#endif
// lock the main thread and abort it
mutex_t::scoped_lock l(m_mutex);
m_abort = true;
m_io_service.stop();
l.unlock();
m_thread->join();
// it's important that the main thread is closed completely before