forked from premiere/premiere-libtorrent
*** empty log message ***
This commit is contained in:
parent
705e40fda6
commit
bc774ff491
|
@ -103,9 +103,9 @@ namespace libtorrent
|
||||||
struct file_logger: libtorrent::logger
|
struct file_logger: libtorrent::logger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
file_logger(const char* filename)
|
file_logger(boost::filesystem::path const& filename)
|
||||||
: m_file(boost::filesystem::complete(filename))
|
: m_file(boost::filesystem::complete("libtorrent_logs" / filename))
|
||||||
{ assert(filename); }
|
{}
|
||||||
virtual void log(const char* text) { assert(text); m_file << text; }
|
virtual void log(const char* text) { assert(text); m_file << text; }
|
||||||
|
|
||||||
boost::filesystem::ofstream m_file;
|
boost::filesystem::ofstream m_file;
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace libtorrent
|
||||||
// marked as being downloaded. If the user of this function
|
// marked as being downloaded. If the user of this function
|
||||||
// decides to download a piece, it must mark it as being downloaded
|
// decides to download a piece, it must mark it as being downloaded
|
||||||
// itself, by using the mark_as_downloading() member function.
|
// itself, by using the mark_as_downloading() member function.
|
||||||
// THIS IS DONE BY THE peer_connection::request_piece() MEMBER FUNCTION!
|
// THIS IS DONE BY THE peer_connection::send_request() MEMBER FUNCTION!
|
||||||
void pick_pieces(const std::vector<bool>& pieces,
|
void pick_pieces(const std::vector<bool>& pieces,
|
||||||
std::vector<piece_block>& interesting_blocks,
|
std::vector<piece_block>& interesting_blocks,
|
||||||
int num_pieces) const;
|
int num_pieces) const;
|
||||||
|
|
|
@ -256,7 +256,7 @@ namespace libtorrent
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void check_invariant(const char *place = 0);
|
void check_invariant(const char *place = 0);
|
||||||
boost::shared_ptr<logger> create_log(std::string name);
|
boost::shared_ptr<logger> create_log(std::string const& name);
|
||||||
boost::shared_ptr<logger> m_logger;
|
boost::shared_ptr<logger> m_logger;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,6 +82,8 @@ namespace libtorrent
|
||||||
, total_payload_upload(0)
|
, total_payload_upload(0)
|
||||||
, download_rate(0)
|
, download_rate(0)
|
||||||
, upload_rate(0)
|
, upload_rate(0)
|
||||||
|
, download_payload_rate(0)
|
||||||
|
, upload_payload_rate(0)
|
||||||
, num_peers(0)
|
, num_peers(0)
|
||||||
, pieces(0)
|
, pieces(0)
|
||||||
, total_done(0)
|
, total_done(0)
|
||||||
|
@ -203,10 +205,9 @@ namespace libtorrent
|
||||||
|
|
||||||
// kind of similar to get_torrent_info() but this
|
// kind of similar to get_torrent_info() but this
|
||||||
// is low level, returning the exact info-part of
|
// is low level, returning the exact info-part of
|
||||||
// the .torrent file. This when hashed, this buffer
|
// the .torrent file. When hashed, this buffer
|
||||||
// will produce the same hash as the info hash.
|
// will produce the info hash. The reference is valid
|
||||||
// the reference is valid only as long as the torrent
|
// only as long as the torrent is running.
|
||||||
// is running.
|
|
||||||
std::vector<char> const& metadata() const;
|
std::vector<char> const& metadata() const;
|
||||||
|
|
||||||
// forces this torrent to reannounce
|
// forces this torrent to reannounce
|
||||||
|
|
|
@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <vector>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "libtorrent/peer_connection.hpp"
|
#include "libtorrent/peer_connection.hpp"
|
||||||
|
@ -783,7 +783,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_requests.size() > 40)
|
if (m_requests.size() > 100)
|
||||||
{
|
{
|
||||||
// don't allow clients to abuse our
|
// don't allow clients to abuse our
|
||||||
// memory consumption.
|
// memory consumption.
|
||||||
|
@ -804,7 +804,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure this request
|
// make sure this request
|
||||||
// is legal and taht the peer
|
// is legal and that the peer
|
||||||
// is not choked
|
// is not choked
|
||||||
if (r.piece >= 0
|
if (r.piece >= 0
|
||||||
&& r.piece < m_torrent->torrent_file().num_pieces()
|
&& r.piece < m_torrent->torrent_file().num_pieces()
|
||||||
|
@ -2154,8 +2154,9 @@ namespace libtorrent
|
||||||
|
|
||||||
// only add new piece-chunks if the send buffer is small enough
|
// only add new piece-chunks if the send buffer is small enough
|
||||||
// otherwise there will be no end to how large it will be!
|
// otherwise there will be no end to how large it will be!
|
||||||
|
// TODO: the buffer size should probably be dependent on the transfer speed
|
||||||
while (!m_requests.empty()
|
while (!m_requests.empty()
|
||||||
&& ((int)m_send_buffer.size() < m_torrent->block_size())
|
&& ((int)m_send_buffer.size() < m_torrent->block_size() * 6)
|
||||||
&& !m_choked)
|
&& !m_choked)
|
||||||
{
|
{
|
||||||
assert(m_torrent->valid_metadata());
|
assert(m_torrent->valid_metadata());
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// the limits of the download queue size
|
// the limits of the download queue size
|
||||||
max_request_queue = 16,
|
max_request_queue = 100,
|
||||||
min_request_queue = 2,
|
min_request_queue = 2,
|
||||||
|
|
||||||
// the amount of free upload allowed before
|
// the amount of free upload allowed before
|
||||||
|
@ -84,13 +84,14 @@ namespace
|
||||||
, std::vector<peer_connection*> ignore = std::vector<peer_connection*>())
|
, std::vector<peer_connection*> ignore = std::vector<peer_connection*>())
|
||||||
{
|
{
|
||||||
// this will make the number of requests linearly dependent
|
// this will make the number of requests linearly dependent
|
||||||
// on the rate in which we download from the peer. 2.5kB/s and
|
// on the rate in which we download from the peer.
|
||||||
// less will make the desired queue size 2 and at about 70 kB/s
|
// we want the queue to represent:
|
||||||
// it will reach the maximum of 16 requests.
|
const int queue_time = 5; // seconds
|
||||||
// matlab expression to plot:
|
// (if the latency is more than this, the download will stall)
|
||||||
// x = 1:100:100000; plot(x, round(min(max(x ./ 5000 + 1.5, 4), 16)));
|
// so, the queue size is 5 * down_rate / 16 kiB (16 kB is the size of each request)
|
||||||
|
// the minimum request size is 2 and the maximum is 100
|
||||||
|
|
||||||
int desired_queue_size = static_cast<int>(c.statistics().download_rate() / 5000.f + 1.5f);
|
int desired_queue_size = static_cast<int>(5.f * c.statistics().download_rate() / (16 * 1024));
|
||||||
if (desired_queue_size > max_request_queue) desired_queue_size = max_request_queue;
|
if (desired_queue_size > max_request_queue) desired_queue_size = max_request_queue;
|
||||||
if (desired_queue_size < min_request_queue) desired_queue_size = min_request_queue;
|
if (desired_queue_size < min_request_queue) desired_queue_size = min_request_queue;
|
||||||
|
|
||||||
|
@ -571,6 +572,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void policy::pulse()
|
void policy::pulse()
|
||||||
{
|
{
|
||||||
|
if (m_torrent->is_paused()) return;
|
||||||
|
|
||||||
using namespace boost::posix_time;
|
using namespace boost::posix_time;
|
||||||
|
|
||||||
// TODO: we must also remove peers that
|
// TODO: we must also remove peers that
|
||||||
|
|
|
@ -778,12 +778,11 @@ namespace libtorrent { namespace detail
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
boost::shared_ptr<logger> session_impl::create_log(std::string name)
|
boost::shared_ptr<logger> session_impl::create_log(std::string const& name)
|
||||||
{
|
{
|
||||||
name = "libtorrent_log_" + name + ".log";
|
// current options are file_logger, cout_logger and null_logger
|
||||||
// current options are file_logger and cout_logger
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING)
|
||||||
return boost::shared_ptr<logger>(new file_logger(name.c_str()));
|
return boost::shared_ptr<logger>(new file_logger(name + ".log"));
|
||||||
#else
|
#else
|
||||||
return boost::shared_ptr<logger>(new null_logger());
|
return boost::shared_ptr<logger>(new null_logger());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -598,7 +598,6 @@ namespace libtorrent
|
||||||
|
|
||||||
m_policy->connection_closed(*p);
|
m_policy->connection_closed(*p);
|
||||||
m_connections.erase(i);
|
m_connections.erase(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_connection& torrent::connect_to_peer(const address& a)
|
peer_connection& torrent::connect_to_peer(const address& a)
|
||||||
|
@ -1098,7 +1097,10 @@ namespace libtorrent
|
||||||
if (m_have_metadata.empty())
|
if (m_have_metadata.empty())
|
||||||
m_have_metadata.resize(256, false);
|
m_have_metadata.resize(256, false);
|
||||||
|
|
||||||
std::pair<int, int> req = offset_to_req(std::make_pair(offset, size), total_size);
|
std::pair<int, int> req = offset_to_req(std::make_pair(offset, size)
|
||||||
|
, total_size);
|
||||||
|
|
||||||
|
assert(req.first + req.second <= m_have_metadata.size());
|
||||||
|
|
||||||
std::fill(
|
std::fill(
|
||||||
m_have_metadata.begin() + req.first
|
m_have_metadata.begin() + req.first
|
||||||
|
@ -1120,7 +1122,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::fill(
|
std::fill(
|
||||||
m_have_metadata.begin()
|
m_have_metadata.begin()
|
||||||
, m_have_metadata.end() + req.first + req.second
|
, m_have_metadata.begin() + req.first + req.second
|
||||||
, false);
|
, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,12 +336,16 @@ namespace libtorrent
|
||||||
void tracker_manager::tick()
|
void tracker_manager::tick()
|
||||||
{
|
{
|
||||||
tracker_connections_t::iterator i;
|
tracker_connections_t::iterator i;
|
||||||
for (i = m_connections.begin(); i != m_connections.end(); ++i)
|
for (i = m_connections.begin(); i != m_connections.end();)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<tracker_connection>& c = *i;
|
boost::shared_ptr<tracker_connection>& c = *i;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!c->tick()) continue;
|
if (!c->tick())
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue