fix CPU busy loop issue in tracker announce logic

This commit is contained in:
Arvid Norberg 2011-09-12 05:21:16 +00:00
parent 469414d486
commit 460799d600
2 changed files with 20 additions and 20 deletions

View File

@ -91,6 +91,7 @@
incoming connection
* added more detailed instrumentation of the disk I/O thread
* fix CPU busy loop issue in tracker announce logic
* honor IOV_MAX when using writev and readv
* don't post 'operation aborted' UDP errors when changing listen port
* fix tracker retry logic, where in some configurations the next tier would not be tried

View File

@ -2329,14 +2329,8 @@ ctx->set_verify_callback(verify_function, ec);
if (ae.is_working()) { tier = ae.tier; sent_announce = false; }
if (!ae.can_announce(now, is_seed()))
{
if (ae.is_working())
{
sent_announce = true; // this counts
if (!settings().announce_to_all_trackers
&& !settings().announce_to_all_tiers)
break;
}
// this counts
if (ae.is_working()) sent_announce = true;
continue;
}
@ -2399,8 +2393,8 @@ ctx->set_verify_callback(verify_function, ec);
}
else
#endif
m_ses.m_tracker_manager.queue_request(m_ses.m_io_service, m_ses.m_half_open, req
, tracker_login() , shared_from_this());
m_ses.m_tracker_manager.queue_request(m_ses.m_io_service, m_ses.m_half_open, req
, tracker_login() , shared_from_this());
ae.updating = true;
ae.next_announce = now + seconds(20);
ae.min_announce = now + seconds(10);
@ -6944,14 +6938,20 @@ ctx->set_verify_callback(verify_function, ec);
if (i->tier > tier && !settings().announce_to_all_tiers) break;
if (i->is_working()) { tier = i->tier; found_working = false; }
if (i->fails >= i->fail_limit && i->fail_limit != 0) continue;
if (i->updating) { found_working = true; continue; }
ptime next_tracker_announce = (std::max)(i->next_announce, i->min_announce);
if (!i->updating
&& next_tracker_announce < next_announce
&& (!found_working || i->is_working()))
next_announce = next_tracker_announce;
if (i->updating)
{
found_working = true;
}
else
{
ptime next_tracker_announce = (std::max)(i->next_announce, i->min_announce);
if (next_tracker_announce < next_announce
&& (!found_working || i->is_working()))
next_announce = next_tracker_announce;
}
if (i->is_working()) found_working = true;
if (!settings().announce_to_all_trackers
if (found_working
&& !settings().announce_to_all_trackers
&& !settings().announce_to_all_tiers) break;
}
@ -6968,9 +6968,8 @@ ctx->set_verify_callback(verify_function, ec);
error_code ec;
boost::weak_ptr<torrent> self(shared_from_this());
// since we don't know if we have to re-issue the async_wait or not
// always do it
// if (m_tracker_timer.expires_at() <= next_announce) return;
// don't re-issue the timer if it's the same expiration time as last time
if (m_tracker_timer.expires_at() == next_announce) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("tracker::on_tracker_announce_disp");