updated piece_picker fix and added another invariant check to policy

This commit is contained in:
Arvid Norberg 2007-08-21 01:17:42 +00:00
parent a443225d49
commit 6c50adabfc
4 changed files with 17 additions and 8 deletions

View File

@ -20,10 +20,8 @@ project client_test
; ;
exe client_test : client_test.cpp exe client_test : client_test.cpp
: <boost>source:<library>/boost/program_options : <library>/boost/program_options
<boost>source:<library>/boost/regex <library>/boost/regex
<boost>system:<library>program-options
<boost>system:<library>regex
; ;
exe simple_client : simple_client.cpp ; exe simple_client : simple_client.cpp ;

View File

@ -280,6 +280,7 @@ namespace libtorrent
{ {
if (p.is_requested(*i)) if (p.is_requested(*i))
{ {
if (num_requests <= 0) break;
// don't request pieces we already have in our request queue // don't request pieces we already have in our request queue
const std::deque<piece_block>& dq = c.download_queue(); const std::deque<piece_block>& dq = c.download_queue();
const std::deque<piece_block>& rq = c.request_queue(); const std::deque<piece_block>& rq = c.request_queue();
@ -299,10 +300,9 @@ namespace libtorrent
assert(p.num_peers(*i) == 1); assert(p.num_peers(*i) == 1);
assert(p.is_requested(*i)); assert(p.is_requested(*i));
num_requests--; num_requests--;
if (num_requests == 0) break;
} }
if (busy_pieces.empty() || num_requests == 0) if (busy_pieces.empty() || num_requests <= 0)
{ {
// in this case, we could not find any blocks // in this case, we could not find any blocks
// that was free. If we couldn't find any busy // that was free. If we couldn't find any busy
@ -1405,6 +1405,11 @@ namespace libtorrent
, boost::bind(std::equal_to<peer_connection*>(), _1, p.connection)) , boost::bind(std::equal_to<peer_connection*>(), _1, p.connection))
!= conns.end()); != conns.end());
} }
if (p.optimistically_unchoked)
{
assert(p.connection);
assert(!p.connection->is_choked());
}
assert(p.connection->peer_info_struct() == 0 assert(p.connection->peer_info_struct() == 0
|| p.connection->peer_info_struct() == &p); || p.connection->peer_info_struct() == &p);
++nonempty_connections; ++nonempty_connections;

View File

@ -674,7 +674,7 @@ namespace libtorrent
{ {
assert(m_piece_length > 0); assert(m_piece_length > 0);
if ((m_urls.empty() && m_nodes.empty()) || m_files.empty()) if (m_files.empty())
{ {
// TODO: throw something here // TODO: throw something here
// throw // throw

View File

@ -2,9 +2,11 @@
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include "libtorrent/file_pool.hpp" #include "libtorrent/file_pool.hpp"
#include "libtorrent/storage.hpp" #include "libtorrent/storage.hpp"
#include "libtorrent/bencode.hpp"
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <fstream>
#include "test.hpp" #include "test.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
@ -55,7 +57,11 @@ void test_transfer()
} }
// to calculate the info_hash // to calculate the info_hash
torrent_file.create_torrent(); entry te = torrent_file.create_torrent();
te.print(std::cout);
// std::ofstream torrent("web_seed.torrent", std::ios::binary | std::ios::trunc);
// bencode(std::ostream_iterator<char>(torrent), te);
session ses; session ses;
ses.set_severity_level(alert::debug); ses.set_severity_level(alert::debug);