lt sync 2071

This commit is contained in:
Marcos Pinto 2008-03-16 05:48:37 +00:00
parent 92dea4475c
commit e033024fbd
4 changed files with 40 additions and 9 deletions

View File

@ -386,7 +386,7 @@ void routing_table::find_node(node_id const& target
// [0, bucket_index) if we are to include ourself // [0, bucket_index) if we are to include ourself
// or [1, bucket_index) if not. // or [1, bucket_index) if not.
bucket_t tmpb; bucket_t tmpb;
for (int i = include_self?0:1; i < count; ++i) for (int i = include_self?0:1; i < bucket_index; ++i)
{ {
bucket_t& b = m_buckets[i].first; bucket_t& b = m_buckets[i].first;
std::remove_copy_if(b.begin(), b.end(), std::back_inserter(tmpb) std::remove_copy_if(b.begin(), b.end(), std::back_inserter(tmpb)

View File

@ -1345,15 +1345,10 @@ namespace libtorrent
// remove the request that just finished // remove the request that just finished
// from the download queue plus the // from the download queue plus the
// skipped blocks. // skipped blocks.
m_download_queue.erase(m_download_queue.begin() m_download_queue.erase(m_download_queue.begin(), b);
, boost::next(b)); b = m_download_queue.begin();
TORRENT_ASSERT(*b == block_finished);
} }
else
{
m_download_queue.erase(b);
}
t->cancel_block(block_finished);
} }
else else
{ {
@ -1380,6 +1375,7 @@ namespace libtorrent
{ {
t->received_redundant_data(p.length); t->received_redundant_data(p.length);
m_download_queue.erase(b);
request_a_block(*t, *this); request_a_block(*t, *this);
send_block_requests(); send_block_requests();
return; return;
@ -1389,7 +1385,16 @@ namespace libtorrent
, self(), _1, _2, p, t)); , self(), _1, _2, p, t));
m_outstanding_writing_bytes += p.length; m_outstanding_writing_bytes += p.length;
TORRENT_ASSERT(!m_reading); TORRENT_ASSERT(!m_reading);
m_download_queue.erase(b);
// did we request this block from any other peers?
bool multi = picker.num_peers(block_finished) > 1;
picker.mark_as_writing(block_finished, peer_info_struct()); picker.mark_as_writing(block_finished, peer_info_struct());
// if we requested this block from other peers, cancel it now
if (multi) t->cancel_block(block_finished);
#ifndef NDEBUG #ifndef NDEBUG
t->check_invariant(); t->check_invariant();
#endif #endif

View File

@ -1534,6 +1534,8 @@ namespace libtorrent
void torrent::cancel_block(piece_block block) void torrent::cancel_block(piece_block block)
{ {
INVARIANT_CHECK;
for (peer_iterator i = m_connections.begin() for (peer_iterator i = m_connections.begin()
, end(m_connections.end()); i != end; ++i) , end(m_connections.end()); i != end; ++i)
{ {

View File

@ -471,6 +471,8 @@ void upnp::post(upnp::rootdevice const& d, std::string const& soap
, std::string const& soap_action) , std::string const& soap_action)
{ {
TORRENT_ASSERT(d.magic == 1337); TORRENT_ASSERT(d.magic == 1337);
TORRENT_ASSERT(d.upnp_connection);
std::stringstream header; std::stringstream header;
header << "POST " << d.control_url << " HTTP/1.1\r\n" header << "POST " << d.control_url << " HTTP/1.1\r\n"
@ -491,6 +493,17 @@ void upnp::post(upnp::rootdevice const& d, std::string const& soap
void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i) void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
{ {
TORRENT_ASSERT(d.magic == 1337); TORRENT_ASSERT(d.magic == 1337);
if (!d.upnp_connection)
{
TORRENT_ASSERT(d.disabled);
#ifdef TORRENT_UPNP_LOGGING
m_log << time_now_string() << " *** mapping (" << i
<< ") aborted" << std::endl;
#endif
return;
}
std::string soap_action = "AddPortMapping"; std::string soap_action = "AddPortMapping";
std::stringstream soap; std::stringstream soap;
@ -548,6 +561,17 @@ void upnp::map_port(rootdevice& d, int i)
void upnp::delete_port_mapping(rootdevice& d, int i) void upnp::delete_port_mapping(rootdevice& d, int i)
{ {
TORRENT_ASSERT(d.magic == 1337); TORRENT_ASSERT(d.magic == 1337);
if (!d.upnp_connection)
{
TORRENT_ASSERT(d.disabled);
#ifdef TORRENT_UPNP_LOGGING
m_log << time_now_string() << " *** unmapping (" << i
<< ") aborted" << std::endl;
#endif
return;
}
std::stringstream soap; std::stringstream soap;
std::string soap_action = "DeletePortMapping"; std::string soap_action = "DeletePortMapping";