local service discovery fixes

This commit is contained in:
Arvid Norberg 2010-02-13 16:29:17 +00:00
parent ef48784cbd
commit 78363cc05d
3 changed files with 16 additions and 4 deletions

View File

@ -464,7 +464,7 @@ void print_peer_info(std::string& out, std::vector<libtorrent::peer_info> const&
{
bool unchoked = (i->flags & peer_info::choked) == 0;
snprintf(str, sizeof(str), " %s %s %s"
snprintf(str, sizeof(str), " %s %s"
, add_suffix(i->remote_dl_rate, "/s").c_str()
, unchoked ? add_suffix(i->estimated_reciprocation_rate, "/s").c_str() : " ");
out += str;

View File

@ -1086,6 +1086,16 @@ namespace aux {
m_unchoke_time_scaler = 0;
}
if (m_settings.local_service_announce_interval != s.local_service_announce_interval)
{
error_code ec;
int delay = (std::max)(s.local_service_announce_interval
/ (std::max)(int(m_torrents.size()), 1), 1);
m_lsd_announce_timer.expires_from_now(seconds(delay), ec);
m_lsd_announce_timer.async_wait(
bind(&session_impl::on_lsd_announce, this, _1));
}
// if queuing settings were changed, recalculate
// queued torrents sooner
if ((m_settings.active_downloads != s.active_downloads
@ -2189,6 +2199,7 @@ namespace aux {
if (e) return;
mutex::scoped_lock l(m_mutex);
if (m_abort) return;
// announce on local network every 5 minutes
int delay = (std::max)(m_settings.local_service_announce_interval
@ -2198,7 +2209,8 @@ namespace aux {
m_lsd_announce_timer.async_wait(
bind(&session_impl::on_lsd_announce, this, _1));
if (m_next_lsd_torrent == m_torrents.end()) return;
if (m_next_lsd_torrent == m_torrents.end())
m_next_lsd_torrent = m_torrents.begin();
m_next_lsd_torrent->second->lsd_announce();
++m_next_lsd_torrent;
if (m_next_lsd_torrent == m_torrents.end())

View File

@ -295,8 +295,8 @@ namespace libtorrent
if (cb)
{
char msg[200];
snprintf(msg, 200, "*** UDP_TRACKER_RESPONSE [ tid: %x%x ]"
, int(transaction >> 32), int(transaction & 0xffffffff));
snprintf(msg, 200, "*** UDP_TRACKER_RESPONSE [ tid: %x ]"
, int(transaction));
cb->debug_log(msg);
}
#endif