*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-10-14 01:17:04 +00:00
parent f324cc925e
commit a8e8c715e8
17 changed files with 125 additions and 110 deletions

View File

@ -57,8 +57,8 @@ example client.</p>
<p>There's a <a class="reference" href="http://lists.sourceforge.net/lists/listinfo/libtorrent-discuss">mailing list</a>, general libtorrent discussion.</p>
<p>You can usually find me as hydri in <tt class="literal"><span class="pre">#btports</span> <span class="pre">&#64;</span> <span class="pre">irc.freenode.net</span></tt>.</p>
</div>
<div class="section" id="aknowledgements">
<h1><a name="aknowledgements">Aknowledgements</a></h1>
<div class="section" id="acknowledgements">
<h1><a name="acknowledgements">Acknowledgements</a></h1>
<p>Written by Arvid Norberg. Copyright (c) 2003</p>
<p>Contributions by Magnus Jonsson and Daniel Wallin</p>
<p>Thanks to Reimond Retz for bugfixes, suggestions and testing</p>

View File

@ -58,7 +58,7 @@ You can usually find me as hydri in ``#btports @ irc.freenode.net``.
Acknowledgements
===============
================
Written by Arvid Norberg. Copyright (c) 2003

View File

@ -115,7 +115,7 @@
</ul>
</li>
<li><a class="reference" href="#filename-checks" id="id96" name="id96">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id97" name="id97">aknowledgements</a></li>
<li><a class="reference" href="#acknowledgements" id="id97" name="id97">acknowledgements</a></li>
</ul>
</div>
<div class="section" id="introduction">
@ -635,11 +635,13 @@ class torrent_info
{
public:
torrent_info(entry const&amp; torrent_file)
torrent_info(int piece_size, const char* name);
torrent_info();
torrent_info(sha1_hash const&amp; info_hash);
torrent_info(entry const&amp; torrent_file);
entry create_torrent() const;
void set_comment(char const* str);
void set_piece_size(int size);
void set_creator(char const* str);
void set_hash(int index, const sha1_hash&amp; h);
void add_tracker(std::string const&amp; url, int tier = 0);
@ -2326,8 +2328,8 @@ boost::filesystem::path::default_name_check(boost::filesystem::native);
</pre>
<p>for example. For more information, see the <a class="reference" href="http://www.boost.org/libs/filesystem/doc/index.htm">Boost.Filesystem docs</a>.</p>
</div>
<div class="section" id="aknowledgements">
<h1><a name="aknowledgements">aknowledgements</a></h1>
<div class="section" id="acknowledgements">
<h1><a name="acknowledgements">acknowledgements</a></h1>
<p>Written by Arvid Norberg. Copyright (c) 2003</p>
<p>Contributions by Magnus Jonsson and Daniel Wallin</p>
<p>Thanks to Reimond Retz for bugfixes, suggestions and testing</p>

View File

@ -559,11 +559,13 @@ The ``torrent_info`` has the following synopsis::
{
public:
torrent_info(entry const& torrent_file)
torrent_info(int piece_size, const char* name);
torrent_info();
torrent_info(sha1_hash const& info_hash);
torrent_info(entry const& torrent_file);
entry create_torrent() const;
void set_comment(char const* str);
void set_piece_size(int size);
void set_creator(char const* str);
void set_hash(int index, const sha1_hash& h);
void add_tracker(std::string const& url, int tier = 0);
@ -2318,7 +2320,7 @@ __ http://www.boost.org/libs/filesystem/doc/index.htm
acknowledgements
===============
================
Written by Arvid Norberg. Copyright (c) 2003

View File

@ -36,5 +36,5 @@ exe make_torrent
;
stage bin : dump_torrent simple_client client_test make_torrent ;
stage bin : dump_torrent make_torrent simple_client client_test ;

View File

@ -49,7 +49,7 @@ int main(int argc, char* argv[])
if (argc != 2)
{
std::cerr << "usage: ./simple_cient torrent-file\n"
std::cerr << "usage: ./simple_client torrent-file\n"
"to stop the client, press return.\n";
return 1;
}

View File

@ -41,6 +41,8 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
@ -102,11 +104,11 @@ namespace libtorrent
{
public:
file_logger(const char* filename)
: m_file(filename)
: m_file(boost::filesystem::complete(filename))
{ assert(filename); }
virtual void log(const char* text) { assert(text); m_file << text; }
std::ofstream m_file;
boost::filesystem::ofstream m_file;
};
}

View File

@ -203,7 +203,7 @@ namespace libtorrent
return p.connection == 0
&& p.connected != not_tried_yet
&& second_clock::local_time() - p.connected > minutes(30);
&& second_clock::universal_time() - p.connected > minutes(30);
}
};

View File

@ -486,7 +486,7 @@ namespace libtorrent
inline void torrent::force_tracker_request()
{
namespace time = boost::posix_time;
m_next_request = time::second_clock::local_time();
m_next_request = time::second_clock::universal_time();
}
inline void torrent::set_tracker_login(

View File

@ -37,7 +37,7 @@ namespace libtorrent {
alert::alert(severity_t severity, const std::string& msg)
: m_msg(msg)
, m_severity(severity)
, m_timestamp(boost::posix_time::second_clock::local_time())
, m_timestamp(boost::posix_time::second_clock::universal_time())
{
}

View File

@ -72,6 +72,8 @@ namespace
}
using namespace boost::posix_time;
namespace libtorrent
{
@ -90,7 +92,7 @@ namespace libtorrent
, m_content_encoding(plain)
, m_content_length(0)
, m_recv_pos(0)
, m_request_time(boost::posix_time::second_clock::local_time())
, m_request_time(second_clock::universal_time())
, m_settings(stn)
, m_req(req)
, m_password(password)
@ -213,7 +215,7 @@ namespace libtorrent
using namespace boost::posix_time;
time_duration d = second_clock::local_time() - m_request_time;
time_duration d = second_clock::universal_time() - m_request_time;
if (d > seconds(m_settings.tracker_timeout) ||
(!has_requester() && d > seconds(m_settings.stop_tracker_timeout)))
{
@ -247,7 +249,7 @@ namespace libtorrent
}
if (sent != 0)
m_request_time = boost::posix_time::second_clock::local_time();
m_request_time = second_clock::universal_time();
}
if (m_socket->has_error())
@ -260,7 +262,7 @@ namespace libtorrent
// if the socket isn't ready for reading, there's no point in continuing
// trying to read from it
if (!m_socket->is_readable()) return false;
m_request_time = boost::posix_time::second_clock::local_time();
m_request_time = second_clock::universal_time();
#ifndef NDEBUG
if (has_requester()) requester().debug_log("tracker connection socket readable");

View File

@ -56,6 +56,8 @@ namespace std
#define VERBOSE
using namespace boost::posix_time;
namespace libtorrent
{
@ -90,8 +92,8 @@ namespace libtorrent
, m_timeout(120)
, m_packet_size(1)
, m_recv_pos(0)
, m_last_receive(boost::posix_time::second_clock::local_time())
, m_last_sent(boost::posix_time::second_clock::local_time())
, m_last_receive(second_clock::universal_time())
, m_last_sent(second_clock::universal_time())
, m_selector(sel)
, m_socket(s)
, m_torrent(t)
@ -110,10 +112,10 @@ namespace libtorrent
, m_free_upload(0)
, m_trust_points(0)
, m_num_invalid_requests(0)
, m_last_piece(boost::posix_time::second_clock::local_time())
, m_last_piece(second_clock::universal_time())
, m_disconnecting(false)
, m_became_uninterested(boost::posix_time::second_clock::local_time())
, m_became_uninteresting(boost::posix_time::second_clock::local_time())
, m_became_uninterested(second_clock::universal_time())
, m_became_uninteresting(second_clock::universal_time())
, m_no_metadata(
boost::gregorian::date(1970, boost::date_time::Jan, 1)
, boost::posix_time::seconds(0))
@ -167,8 +169,8 @@ namespace libtorrent
, m_timeout(120)
, m_packet_size(1)
, m_recv_pos(0)
, m_last_receive(boost::posix_time::second_clock::local_time())
, m_last_sent(boost::posix_time::second_clock::local_time())
, m_last_receive(second_clock::universal_time())
, m_last_sent(second_clock::universal_time())
, m_selector(sel)
, m_socket(s)
, m_torrent(0)
@ -188,10 +190,10 @@ namespace libtorrent
, m_free_upload(0)
, m_trust_points(0)
, m_num_invalid_requests(0)
, m_last_piece(boost::posix_time::second_clock::local_time())
, m_last_piece(second_clock::universal_time())
, m_disconnecting(false)
, m_became_uninterested(boost::posix_time::second_clock::local_time())
, m_became_uninteresting(boost::posix_time::second_clock::local_time())
, m_became_uninterested(second_clock::universal_time())
, m_became_uninteresting(second_clock::universal_time())
, m_no_metadata(
boost::gregorian::date(1970, boost::date_time::Jan, 1)
, boost::posix_time::seconds(0))
@ -431,7 +433,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> HANDSHAKE\n";
#endif
@ -503,7 +505,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== CHOKE\n";
#endif
m_peer_choked = true;
@ -539,7 +541,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== UNCHOKE\n";
#endif
m_peer_choked = false;
@ -562,7 +564,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== INTERESTED\n";
#endif
m_peer_interested = true;
@ -583,7 +585,7 @@ namespace libtorrent
m_statistics.received_bytes(0, received);
if (m_recv_pos < m_packet_size) return;
m_became_uninterested = boost::posix_time::second_clock::local_time();
m_became_uninterested = second_clock::universal_time();
// clear the request queue if the client isn't interested
m_requests.clear();
@ -591,7 +593,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== NOT_INTERESTED\n";
#endif
m_peer_interested = false;
@ -620,7 +622,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== HAVE [ piece: " << index << "]\n";
#endif
@ -673,7 +675,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== BITFIELD\n";
#endif
@ -769,7 +771,7 @@ namespace libtorrent
// we shouldn't get a request
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== UNEXPECTED_REQUEST [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -789,7 +791,7 @@ namespace libtorrent
// is making too many of them.
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== TOO MANY REQUESTS [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -822,7 +824,7 @@ namespace libtorrent
send_buffer_updated();
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== REQUEST [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
#endif
}
@ -830,7 +832,7 @@ namespace libtorrent
{
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== INVALID_REQUEST [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -865,7 +867,7 @@ namespace libtorrent
assert(received > 0);
if (m_recv_pos - received <= 9)
{
m_last_piece = boost::posix_time::second_clock::local_time();
m_last_piece = second_clock::universal_time();
}
// classify the received data as protocol chatter
// or data payload for the statistics
@ -898,7 +900,7 @@ namespace libtorrent
{
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== INVALID_PIECE [ piece: " << p.piece << " | "
"start: " << p.start << " | "
"length: " << p.length << " ]\n";
@ -916,11 +918,11 @@ namespace libtorrent
&& i->block_index == p.start / m_torrent->block_size())
break;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " *** SKIPPED_PIECE [ piece: " << i->piece_index << " | "
"b: " << i->block_index << " ] ***\n";
}
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== PIECE [ piece: " << p.piece << " | "
"b: " << p.start / m_torrent->block_size() << " | "
"s: " << p.start << " | "
@ -1040,7 +1042,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== CANCEL [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
#endif
}
@ -1223,7 +1225,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " <== METADATA [ tot: " << total_size << " offset: "
<< offset << " size: " << data_size << " ]\n";
#endif
@ -1234,7 +1236,7 @@ namespace libtorrent
}
break;
case 2: // have no data
m_no_metadata = boost::posix_time::second_clock::local_time();
m_no_metadata = second_clock::universal_time();
if (m_waiting_metadata_request)
m_torrent->cancel_metadata_request(m_last_metadata_request);
m_waiting_metadata_request = false;
@ -1267,7 +1269,7 @@ namespace libtorrent
if (is_local())
{
#ifndef NDEBUG
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< "<== LISTEN_PORT [ UNEXPECTED ]\n";
#endif
return;
@ -1277,7 +1279,7 @@ namespace libtorrent
unsigned short port = detail::read_uint16(ptr);
#ifndef NDEBUG
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< "<== LISTEN_PORT [ port: " << port << " ]\n";
#endif
@ -1289,7 +1291,7 @@ namespace libtorrent
bool peer_connection::has_metadata() const
{
using namespace boost::posix_time;
return second_clock::local_time() - m_no_metadata > minutes(5);
return second_clock::universal_time() - m_no_metadata > minutes(5);
}
@ -1378,7 +1380,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> CANCEL [ piece: " << block.piece_index << " | s: " << block_offset << " | l: " << block_size << " | " << block.block_index << " ]\n";
#endif
@ -1426,7 +1428,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> REQUEST [ "
"piece: " << block.piece_index << " | "
"b: " << block.block_index << " | "
@ -1504,7 +1506,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> METADATA_REQUEST [ start: " << req.first
<< " size: " << req.second << " ]\n";
#endif
@ -1550,7 +1552,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> BITFIELD\n";
#endif
const int packet_size = ((int)m_have_piece.size() + 7) / 8 + 5;
@ -1576,7 +1578,7 @@ namespace libtorrent
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> EXTENSIONS\n";
#endif
assert(m_supports_extensions);
@ -1613,7 +1615,7 @@ namespace libtorrent
m_choked = true;
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> CHOKE\n";
#endif
m_num_invalid_requests = 0;
@ -1631,7 +1633,7 @@ namespace libtorrent
m_choked = false;
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> UNCHOKE\n";
#endif
send_buffer_updated();
@ -1647,7 +1649,7 @@ namespace libtorrent
m_interesting = true;
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> INTERESTED\n";
#endif
send_buffer_updated();
@ -1662,11 +1664,11 @@ namespace libtorrent
m_send_buffer.insert(m_send_buffer.end(), msg, msg+sizeof(msg));
m_interesting = false;
m_became_uninteresting = boost::posix_time::second_clock::local_time();
m_became_uninteresting = second_clock::universal_time();
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> NOT_INTERESTED\n";
#endif
send_buffer_updated();
@ -1690,7 +1692,7 @@ namespace libtorrent
m_send_buffer.insert(m_send_buffer.end(), msg, msg + packet_size);
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> HAVE [ piece: " << index << " ]\n";
#endif
send_buffer_updated();
@ -1726,7 +1728,7 @@ namespace libtorrent
m_last_metadata_request = m_torrent->metadata_request();
send_metadata_request(m_last_metadata_request);
m_waiting_metadata_request = true;
m_metadata_request = boost::posix_time::second_clock::local_time();
m_metadata_request = second_clock::universal_time();
}
m_statistics.second_tick();
@ -1865,7 +1867,7 @@ namespace libtorrent
if (received > 0)
{
m_last_receive = boost::posix_time::second_clock::local_time();
m_last_receive = second_clock::universal_time();
m_recv_pos += received;
m_dl_bandwidth_quota.used += received;
@ -2180,7 +2182,7 @@ namespace libtorrent
, r.length);
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> PIECE [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
#endif
@ -2284,7 +2286,7 @@ namespace libtorrent
throw network_error(m_socket->last_error());
}
m_last_sent = boost::posix_time::second_clock::local_time();
m_last_sent = second_clock::universal_time();
}
assert(m_writability_monitored);
@ -2311,7 +2313,7 @@ namespace libtorrent
// if the peer hasn't said a thing for a certain
// time, it is considered to have timed out
time_duration d;
d = second_clock::local_time() - m_last_receive;
d = second_clock::universal_time() - m_last_receive;
if (d > seconds(m_timeout)) return true;
// if the peer hasn't become interested and we haven't
@ -2319,8 +2321,8 @@ namespace libtorrent
// has also timed out.
time_duration d1;
time_duration d2;
d1 = second_clock::local_time() - m_became_uninterested;
d2 = second_clock::local_time() - m_became_uninteresting;
d1 = second_clock::universal_time() - m_became_uninterested;
d2 = second_clock::universal_time() - m_became_uninteresting;
if (!m_interesting
&& !m_peer_interested
&& d1 > seconds(60 * 3)
@ -2337,7 +2339,7 @@ namespace libtorrent
INVARIANT_CHECK;
boost::posix_time::time_duration d;
d = boost::posix_time::second_clock::local_time() - m_last_sent;
d = second_clock::universal_time() - m_last_sent;
if (d.seconds() < m_timeout / 2) return;
// we must either send a keep-alive
@ -2346,10 +2348,10 @@ namespace libtorrent
{
char noop[] = {0,0,0,0};
m_send_buffer.insert(m_send_buffer.end(), noop, noop+4);
m_last_sent = boost::posix_time::second_clock::local_time();
m_last_sent = second_clock::universal_time();
#ifndef NDEBUG
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << to_simple_string(second_clock::universal_time())
<< " ==> NOP\n";
#endif
}

View File

@ -57,6 +57,8 @@ namespace libtorrent
class peer_connection;
}
using namespace boost::posix_time;
namespace
{
enum
@ -409,7 +411,7 @@ namespace libtorrent
double slowest_transfer_rate = std::numeric_limits<double>::max();
boost::posix_time::ptime local_time
= boost::posix_time::second_clock::local_time();
= second_clock::universal_time();
for (std::vector<peer>::iterator i = m_peers.begin();
i != m_peers.end();
@ -446,7 +448,7 @@ namespace libtorrent
policy::peer *policy::find_connect_candidate()
{
boost::posix_time::ptime local_time=boost::posix_time::second_clock::local_time();
boost::posix_time::ptime local_time=second_clock::universal_time();
boost::posix_time::ptime ptime(local_time);
policy::peer* candidate =0;
@ -529,7 +531,7 @@ namespace libtorrent
{
peer* candidate = 0;
boost::posix_time::ptime last_unchoke
= boost::posix_time::second_clock::local_time();
= second_clock::universal_time();
for (std::vector<peer>::iterator i = m_peers.begin();
i != m_peers.end();
@ -554,7 +556,7 @@ namespace libtorrent
{
p->connection->send_unchoke();
p->last_optimistically_unchoked
= boost::posix_time::second_clock::local_time();
= second_clock::universal_time();
++m_num_unchoked;
}
return p != 0;
@ -600,7 +602,7 @@ namespace libtorrent
{
// every minute, disconnect the worst peer in hope of finding a better peer
boost::posix_time::ptime local_time = boost::posix_time::second_clock::local_time();
boost::posix_time::ptime local_time = second_clock::universal_time();
if(m_last_optimistic_disconnect + boost::posix_time::seconds(120) <= local_time)
{
m_last_optimistic_disconnect = local_time;
@ -610,7 +612,7 @@ namespace libtorrent
else
{
// don't do a disconnect earlier than 1 minute after some peer was connected
m_last_optimistic_disconnect = boost::posix_time::second_clock::local_time();
m_last_optimistic_disconnect = second_clock::universal_time();
}
while (num_connected_peers > max_connections)
@ -817,8 +819,8 @@ namespace libtorrent
i->prev_amount_download = 0;
i->prev_amount_upload = 0;
i->connection = &c;
i->connected = boost::posix_time::second_clock::local_time();
m_last_optimistic_disconnect = boost::posix_time::second_clock::local_time();
i->connected = second_clock::universal_time();
m_last_optimistic_disconnect = second_clock::universal_time();
}
void policy::peer_from_tracker(const address& remote, const peer_id& id)
@ -992,7 +994,7 @@ namespace libtorrent
assert(!p->connection->is_disconnecting());
p->connection->send_unchoke();
p->last_optimistically_unchoked = boost::posix_time::second_clock::local_time();
p->last_optimistically_unchoked = second_clock::universal_time();
++m_num_unchoked;
return true;
}
@ -1020,7 +1022,7 @@ namespace libtorrent
p->prev_amount_upload = 0;
p->connected =
m_last_optimistic_disconnect =
boost::posix_time::second_clock::local_time();
second_clock::universal_time();
return true;
}
catch (network_error&)
@ -1052,7 +1054,7 @@ namespace libtorrent
if (i == m_peers.end()) return;
assert(i->connection == &c);
i->connected = boost::posix_time::second_clock::local_time();
i->connected = second_clock::universal_time();
if (!i->connection->is_choked() && !m_torrent->is_aborted())
{
// if the peer that is diconnecting is unchoked
@ -1139,7 +1141,7 @@ namespace libtorrent
, banned(false)
, connection(0)
{
assert(connected < boost::posix_time::second_clock::local_time());
assert(connected < second_clock::universal_time());
}
size_type policy::peer::total_download() const

View File

@ -77,6 +77,8 @@ namespace std
};
#endif
using namespace boost::posix_time;
namespace libtorrent { namespace detail
{
@ -320,7 +322,7 @@ namespace libtorrent { namespace detail
std::vector<boost::shared_ptr<socket> > readable_clients;
std::vector<boost::shared_ptr<socket> > writable_clients;
std::vector<boost::shared_ptr<socket> > error_clients;
boost::posix_time::ptime timer = boost::posix_time::second_clock::local_time();
boost::posix_time::ptime timer = second_clock::universal_time();
#ifndef NDEBUG
int loops_per_second = 0;
@ -597,9 +599,9 @@ namespace libtorrent { namespace detail
check_invariant("after ERROR SOCKETS");
#endif
boost::posix_time::time_duration d = boost::posix_time::second_clock::local_time() - timer;
boost::posix_time::time_duration d = second_clock::universal_time() - timer;
if (d.seconds() < 1) continue;
timer = boost::posix_time::second_clock::local_time();
timer = second_clock::universal_time();
// ************************
// THE SECTION BELOW IS EXECUTED ONCE EVERY SECOND

View File

@ -72,6 +72,7 @@ namespace std
#endif
using namespace libtorrent;
using namespace boost::posix_time;
namespace
@ -157,7 +158,7 @@ namespace libtorrent
, m_event(tracker_request::started)
, m_block_size(0)
, m_storage(0)
, m_next_request(boost::posix_time::second_clock::local_time())
, m_next_request(second_clock::universal_time())
, m_duration(1800)
, m_policy()
, m_ses(ses)
@ -195,7 +196,7 @@ namespace libtorrent
, m_event(tracker_request::started)
, m_block_size(0)
, m_storage(0)
, m_next_request(boost::posix_time::second_clock::local_time())
, m_next_request(second_clock::universal_time())
, m_duration(1800)
, m_policy()
, m_ses(ses)
@ -247,14 +248,13 @@ namespace libtorrent
// tracker request
bool torrent::should_request()
{
namespace time = boost::posix_time;
if (m_just_paused)
{
m_just_paused = false;
return true;
}
return !m_paused &&
m_next_request < time::second_clock::local_time();
m_next_request < second_clock::universal_time();
}
void torrent::tracker_response(
@ -268,7 +268,7 @@ namespace libtorrent
m_last_working_tracker
= prioritize_tracker(m_currently_trying_tracker);
m_next_request = boost::posix_time::second_clock::local_time()
m_next_request = second_clock::universal_time()
+ boost::posix_time::seconds(m_duration);
m_currently_trying_tracker = 0;
@ -277,11 +277,11 @@ namespace libtorrent
{
// if the peer list is empty, we should contact the
// tracker soon again to see if there are any peers
m_next_request = boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(60);
m_next_request = second_clock::universal_time() + boost::posix_time::seconds(60);
}
else
{
m_next_request = boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(m_duration);
m_next_request = second_clock::universal_time() + boost::posix_time::seconds(m_duration);
}
// connect to random peers from the list
@ -521,7 +521,7 @@ namespace libtorrent
{
m_duration = 1800;
m_next_request
= boost::posix_time::second_clock::local_time()
= second_clock::universal_time()
+ boost::posix_time::seconds(tracker_retry_delay_max);
tracker_request req;
@ -698,12 +698,12 @@ namespace libtorrent
++m_failed_trackers;
// if we've looped the tracker list, wait a bit before retrying
m_currently_trying_tracker = 0;
m_next_request = second_clock::local_time() + seconds(delay);
m_next_request = second_clock::universal_time() + seconds(delay);
}
else
{
// don't delay before trying the next tracker
m_next_request = boost::posix_time::second_clock::local_time();
m_next_request = second_clock::universal_time();
}
}
@ -944,7 +944,7 @@ namespace libtorrent
st.upload_payload_rate = m_stat.upload_payload_rate();
st.next_announce = next_announce()
- boost::posix_time::second_clock::local_time();
- second_clock::universal_time();
if (st.next_announce.is_negative()) st.next_announce
= boost::posix_time::seconds(0);
st.announce_interval = boost::posix_time::seconds(m_duration);

View File

@ -128,7 +128,7 @@ namespace libtorrent
, m_total_size(0)
, m_info_hash(info_hash)
, m_name()
, m_creation_date(second_clock::local_time())
, m_creation_date(second_clock::universal_time())
{
}
@ -137,7 +137,7 @@ namespace libtorrent
, m_total_size(0)
, m_info_hash(0)
, m_name()
, m_creation_date(second_clock::local_time())
, m_creation_date(second_clock::universal_time())
{
}
@ -363,13 +363,12 @@ namespace libtorrent
entry info(entry::dictionary_t);
info["length"] = m_total_size;
assert(!m_files.empty());
if (m_files.size() == 1)
{
info["name"] = m_name;
info["length"] = m_files.front().size;
}
else
{

View File

@ -54,6 +54,8 @@ namespace
};
}
using namespace boost::posix_time;
namespace libtorrent
{
@ -64,7 +66,7 @@ namespace libtorrent
, boost::weak_ptr<request_callback> c
, const http_settings& stn)
: tracker_connection(c)
, m_request_time(boost::posix_time::second_clock::local_time())
, m_request_time(second_clock::universal_time())
, m_request(req)
, m_transaction_id(0)
, m_connection_id(0)
@ -85,7 +87,7 @@ namespace libtorrent
{
using namespace boost::posix_time;
time_duration d = second_clock::local_time() - m_request_time;
time_duration d = second_clock::universal_time() - m_request_time;
return (m_transaction_id != 0
&& m_connection_id != 0)
|| d > seconds(m_settings.tracker_timeout);
@ -95,7 +97,7 @@ namespace libtorrent
{
using namespace boost::posix_time;
time_duration d = second_clock::local_time() - m_request_time;
time_duration d = second_clock::universal_time() - m_request_time;
if (m_connection_id == 0
&& d > seconds(udp_connect_timeout))
{
@ -185,7 +187,7 @@ namespace libtorrent
detail::write_uint16(m_request.listen_port, ptr);
m_socket->send(buf, 94);
m_request_time = boost::posix_time::second_clock::local_time();
m_request_time = second_clock::universal_time();
++m_attempts;
}
@ -205,7 +207,7 @@ namespace libtorrent
detail::write_int32(m_transaction_id, ptr);
m_socket->send(send_buf, 16);
m_request_time = boost::posix_time::second_clock::local_time();
m_request_time = second_clock::universal_time();
++m_attempts;
}