removed some more unecessary boost.date_time dependencies

This commit is contained in:
Arvid Norberg 2007-04-10 07:52:58 +00:00
parent 5be60cc125
commit d88ffcc0e4
29 changed files with 85 additions and 230 deletions

View File

@ -44,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/bind.hpp>
#include <boost/program_options.hpp>
#include <boost/regex.hpp>

View File

@ -48,7 +48,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/smart_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/array.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/optional.hpp>
#include <boost/cstdint.hpp>

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp>
#include <boost/date_time/time_duration.hpp>
#include <vector>
#include <string>

View File

@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/shared_ptr.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
#include <boost/tuple/tuple.hpp>

View File

@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/peer_id.hpp"
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/weak_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/array.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/optional.hpp>
#include <boost/cstdint.hpp>
#include <boost/detail/atomic_count.hpp>

View File

@ -33,10 +33,21 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_TIME_HPP_INCLUDED
#define TORRENT_TIME_HPP_INCLUDED
#include <ctime>
#ifndef _WIN32
#include <unistd.h>
#endif
namespace libtorrent
{
inline char const* time_now_string()
{
time_t t = std::time(0);
return std::ctime(&t);
}
}
#if (!defined (__MACH__) && !defined (_WIN32) && !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0) || defined (TORRENT_USE_BOOST_DATE_TIME)
#include <boost/date_time/posix_time/posix_time.hpp>
@ -69,7 +80,6 @@ namespace libtorrent
#else
#include <asio/time_traits.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
namespace libtorrent

View File

@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/limits.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/scoped_ptr.hpp>

View File

@ -41,8 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/shared_ptr.hpp>

View File

@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/shared_ptr.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/intrusive_ptr.hpp>

View File

@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/shared_ptr.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
#ifdef _MSC_VER

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/weak_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/array.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/optional.hpp>
#include <boost/cstdint.hpp>

View File

@ -50,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions.hpp"
#include "libtorrent/aux_/session_impl.hpp"
using namespace boost::posix_time;
using boost::bind;
using boost::shared_ptr;
using libtorrent::aux::session_impl;
@ -166,8 +165,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " ==> DHT_PORT [ " << listen_port << " ]\n";
#endif
buffer::interval packet = allocate_send_buffer(7);
@ -301,9 +299,7 @@ namespace libtorrent
assert(i.begin == i.end);
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> HANDSHAKE\n";
(*m_logger) << time_now_string() << " ==> HANDSHAKE\n";
#endif
setup_send();
}
@ -352,9 +348,7 @@ namespace libtorrent
INVARIANT_CHECK;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== KEEPALIVE\n";
(*m_logger) << time_now_string() << " <== KEEPALIVE\n";
#endif
incoming_keepalive();
}
@ -825,9 +819,7 @@ namespace libtorrent
assert(t->valid_metadata());
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> BITFIELD ";
(*m_logger) << time_now_string() << " ==> BITFIELD ";
for (int i = 0; i < (int)get_bitfield().size(); ++i)
{
@ -862,9 +854,7 @@ namespace libtorrent
INVARIANT_CHECK;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> EXTENSIONS\n";
(*m_logger) << time_now_string() << " ==> EXTENSIONS\n";
#endif
assert(m_supports_extensions);

View File

@ -86,8 +86,6 @@ namespace
}
using namespace boost::posix_time;
namespace
{
bool url_has_argument(std::string const& url, std::string argument)

View File

@ -296,10 +296,7 @@ namespace libtorrent { namespace dht
if (first)
{
first = false;
using boost::posix_time::to_simple_string;
using boost::posix_time::second_clock;
pc << "\n\n ***** starting log at " << to_simple_string(
second_clock::universal_time()) << " *****\n\n"
pc << "\n\n ***** starting log at " << time_now_string() << " *****\n\n"
<< "minute:active nodes:passive nodes"
":ping replies sent:ping queries recvd:ping"
":ping replies sent:ping queries recvd:ping"

View File

@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
@ -72,9 +71,7 @@ namespace libtorrent { namespace
void log_timestamp()
{
using namespace boost::posix_time;
std::string now(to_simple_string(second_clock::local_time()));
m_file << now << ": ";
m_file << time_now_string() << ": ";
}
// can add entries to the extension handshake

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/xml_parse.hpp"
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <asio/ip/host_name.hpp>
#include <asio/ip/multicast.hpp>
#include <boost/thread/mutex.hpp>
@ -46,11 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
using boost::bind;
using namespace libtorrent;
using boost::posix_time::microsec_clock;
using boost::posix_time::milliseconds;
using boost::posix_time::seconds;
using boost::posix_time::second_clock;
using boost::posix_time::ptime;
namespace
{
@ -161,7 +155,7 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
, lsd_multicast_endpoint);
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " ==> announce: ih: " << ih << " port: " << listen_port << std::endl;
#endif
@ -171,7 +165,6 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
void lsd::resend_announce(asio::error_code const& e, std::string msg)
{
using boost::posix_time::hours;
if (e) return;
m_socket.send_to(asio::buffer(msg, msg.size() - 1)
@ -189,11 +182,10 @@ void lsd::on_announce(asio::error_code const& e
, std::size_t bytes_transferred)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== on_announce" << std::endl;
#endif
using namespace libtorrent::detail;
using boost::posix_time::seconds;
if (e) return;
char* p = m_receive_buffer;
@ -203,7 +195,7 @@ void lsd::on_announce(asio::error_code const& e
if (line == end || std::strcmp("bt-search", p))
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Got incorrect method in announce" << std::string(p, line) << std::endl;
#endif
setup_receive();
@ -232,7 +224,7 @@ void lsd::on_announce(asio::error_code const& e
if (!ih.is_all_zeros() && port != 0)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Got incoming local announce " << m_remote.address()
<< ":" << port << " ih: " << ih << std::endl;
#endif
@ -246,7 +238,7 @@ void lsd::on_announce(asio::error_code const& e
void lsd::setup_receive()
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " *** setup_receive" << std::endl;
#endif
assert(m_socket.is_open());

View File

@ -37,9 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <asio/ip/host_name.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
using boost::posix_time::microsec_clock;
using boost::bind;
using namespace libtorrent;
@ -97,7 +94,7 @@ void natpmp::rebind(address const& listen_interface)
m_socket.bind(udp::endpoint(local, 0));
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " local ip: " << local.to_string() << std::endl;
#endif
@ -186,7 +183,7 @@ void natpmp::send_map_request(int i) try
write_uint32(ttl, out); // port mapping lifetime
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " ==> port map request: " << (m.protocol == 1 ? "udp" : "tcp")
<< " local: " << m.local_port << " external: " << m.external_port
<< " ttl: " << ttl << std::endl;
@ -251,7 +248,7 @@ void natpmp::on_reply(asio::error_code const& e
(void)time; // to remove warning
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== port map response: " << (cmd - 128 == 1 ? "udp" : "tcp")
<< " local: " << private_port << " external: " << public_port
<< " ttl: " << lifetime << std::endl;

View File

@ -50,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions.hpp"
#include "libtorrent/aux_/session_impl.hpp"
using namespace boost::posix_time;
using boost::bind;
using boost::shared_ptr;
using libtorrent::aux::session_impl;
@ -292,10 +291,9 @@ namespace libtorrent
assert(m_disconnecting);
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
if (m_logger)
{
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " *** CONNECTION CLOSED\n";
}
#endif
@ -312,8 +310,7 @@ namespace libtorrent
if (has_piece(index)) return;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " ==> HAVE [ piece: " << index << "]\n";
#endif
write_have(index);
@ -513,9 +510,7 @@ namespace libtorrent
INVARIANT_CHECK;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== KEEPALIVE\n";
(*m_logger) << time_now_string() << " <== KEEPALIVE\n";
#endif
}
@ -539,9 +534,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== CHOKE\n";
(*m_logger) << time_now_string() << " <== CHOKE\n";
#endif
m_peer_choked = true;
t->get_policy().choked(*this);
@ -589,9 +582,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== UNCHOKE\n";
(*m_logger) << time_now_string() << " <== UNCHOKE\n";
#endif
m_peer_choked = false;
t->get_policy().unchoked(*this);
@ -617,9 +608,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== INTERESTED\n";
(*m_logger) << time_now_string() << " <== INTERESTED\n";
#endif
m_peer_interested = true;
t->get_policy().interested(*this);
@ -648,9 +637,7 @@ namespace libtorrent
// setup_send();
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== NOT_INTERESTED\n";
(*m_logger) << time_now_string() << " <== NOT_INTERESTED\n";
#endif
boost::shared_ptr<torrent> t = m_torrent.lock();
@ -680,8 +667,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== HAVE [ piece: " << index << "]\n";
#endif
@ -747,9 +733,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " <== BITFIELD ";
(*m_logger) << time_now_string() << " <== BITFIELD ";
for (int i = 0; i < int(bitfield.size()); ++i)
{
@ -843,8 +827,7 @@ namespace libtorrent
// if we don't have valid metadata yet,
// we shouldn't get a request
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== UNEXPECTED_REQUEST [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -863,8 +846,7 @@ namespace libtorrent
// ignore requests if the client
// is making too many of them.
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== TOO MANY REQUESTS [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -889,8 +871,7 @@ namespace libtorrent
&& m_peer_interested)
{
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== REQUEST [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
#endif
// if we have choked the client
@ -904,8 +885,7 @@ namespace libtorrent
else
{
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== INVALID_REQUEST [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -991,7 +971,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== PIECE [ piece: " << p.piece << " | "
"s: " << p.start << " | "
"l: " << p.length << " | "
@ -1002,8 +982,7 @@ namespace libtorrent
if (!verify_piece(p))
{
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== INVALID_PIECE [ piece: " << p.piece << " | "
"start: " << p.start << " | "
"length: " << p.length << " ]\n";
@ -1011,8 +990,6 @@ namespace libtorrent
throw protocol_error("got invalid piece packet");
}
using namespace boost::posix_time;
// if we're already seeding, don't bother,
// just ignore it
if (t->is_seed())
@ -1049,7 +1026,7 @@ namespace libtorrent
i != b; ++i)
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " *** SKIPPED_PIECE [ piece: " << i->piece_index << " | "
"b: " << i->block_index << " ] ***\n";
#endif
@ -1245,8 +1222,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== CANCEL [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
#endif
@ -1260,9 +1236,7 @@ namespace libtorrent
else
{
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " *** GOT CANCEL NOT IN THE QUEUE\n";
(*m_logger) << time_now_string() << " *** GOT CANCEL NOT IN THE QUEUE\n";
#endif
}
}
@ -1276,8 +1250,7 @@ namespace libtorrent
INVARIANT_CHECK;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " <== DHT_PORT [ p: " << listen_port << " ]\n";
#endif
#ifndef TORRENT_DISABLE_DHT
@ -1353,8 +1326,7 @@ namespace libtorrent
write_cancel(r);
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " ==> CANCEL [ piece: " << block.piece_index << " | s: "
<< block_offset << " | l: " << block_size << " | " << block.block_index << " ]\n";
#endif
@ -1369,12 +1341,9 @@ namespace libtorrent
m_choked = true;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> CHOKE\n";
(*m_logger) << time_now_string() << " ==> CHOKE\n";
#endif
#ifndef NDEBUG
using namespace boost::posix_time;
m_last_choke = time_now();
#endif
m_num_invalid_requests = 0;
@ -1390,7 +1359,6 @@ namespace libtorrent
// unchoke, increase this value that interval
// this condition cannot be guaranteed since if peers disconnect
// a new one will be unchoked ignoring when it was last choked
using namespace boost::posix_time;
//assert(time_now() - m_last_choke > seconds(9));
#endif
@ -1399,9 +1367,7 @@ namespace libtorrent
m_choked = false;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> UNCHOKE\n";
(*m_logger) << time_now_string() << " ==> UNCHOKE\n";
#endif
}
@ -1414,9 +1380,7 @@ namespace libtorrent
m_interesting = true;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> INTERESTED\n";
(*m_logger) << time_now_string() << " ==> INTERESTED\n";
#endif
}
@ -1431,9 +1395,7 @@ namespace libtorrent
m_became_uninteresting = time_now();
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
<< " ==> NOT_INTERESTED\n";
(*m_logger) << time_now_string() << " ==> NOT_INTERESTED\n";
#endif
}
@ -1470,7 +1432,7 @@ namespace libtorrent
m_download_queue.push_back(block);
/*
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " *** REQUEST-QUEUE** [ "
"piece: " << block.piece_index << " | "
"block: " << block.block_index << " ]\n";
@ -1489,7 +1451,7 @@ namespace libtorrent
m_download_queue.push_back(block);
/*
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " *** REQUEST-QUEUE** [ "
"piece: " << block.piece_index << " | "
"block: " << block.block_index << " ]\n";
@ -1519,10 +1481,8 @@ namespace libtorrent
write_request(r);
#endif
using namespace boost::posix_time;
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " ==> REQUEST [ "
"piece: " << r.piece << " | "
"s: " << r.start << " | "
@ -1686,7 +1646,7 @@ namespace libtorrent
// in this case we'll clear our download queue and
// re-request the blocks.
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " *** PIECE_REQUESTS TIMED OUT [ " << (int)m_download_queue.size()
<< " " << total_seconds(now - m_last_piece) << "] ***\n";
#endif
@ -1826,8 +1786,7 @@ namespace libtorrent
write_piece(r);
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< " ==> PIECE [ piece: " << r.piece << " | s: " << r.start
<< " | l: " << r.length << " ]\n";
#endif
@ -2348,8 +2307,6 @@ namespace libtorrent
return false;
#endif
using namespace boost::posix_time;
ptime now(time_now());
// if the socket is still connecting, don't

View File

@ -75,7 +75,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/kademlia/dht_tracker.hpp"
using namespace boost::posix_time;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::bind;

View File

@ -75,7 +75,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/kademlia/dht_tracker.hpp"
using namespace boost::posix_time;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::bind;
@ -467,8 +466,7 @@ namespace libtorrent { namespace detail
{
seed_random_generator()
{
std::srand((unsigned int)(boost::posix_time::microsec_clock::
universal_time().time_of_day().total_microseconds()));
std::srand(total_microseconds(time_now() - min_time()));
}
};
@ -507,9 +505,7 @@ namespace libtorrent { namespace detail
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
m_logger = create_log("main_session", listen_port(), false);
using boost::posix_time::second_clock;
using boost::posix_time::to_simple_string;
(*m_logger) << to_simple_string(second_clock::local_time()) << "\n";
(*m_logger) << time_now_string() << "\n";
m_stats_logger = create_log("session_stats", listen_port(), false);
(*m_stats_logger) <<
@ -1488,9 +1484,7 @@ namespace libtorrent { namespace detail
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
m_logger = create_log("main_session", listen_port(), false);
using boost::posix_time::second_clock;
using boost::posix_time::to_simple_string;
(*m_logger) << to_simple_string(second_clock::local_time()) << "\n";
(*m_logger) << time_now_string() << "\n";
#endif
return m_listen_socket;
@ -1516,7 +1510,7 @@ namespace libtorrent { namespace detail
if (!t) return;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << to_simple_string(second_clock::local_time())
(*m_logger) << time_now_string()
<< ": added peer from local discovery: " << peer << "\n";
#endif
t->get_policy().peer_from_tracker(peer, peer_id(0));

View File

@ -48,7 +48,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem/fstream.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/ref.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/bind.hpp>
#include <boost/version.hpp>
#include <boost/multi_index_container.hpp>
@ -208,7 +207,6 @@ bool operator<(boost::filesystem::path const& lhs
#endif
using namespace boost::filesystem;
namespace pt = boost::posix_time;
using boost::bind;
using namespace ::boost::multi_index;
using boost::multi_index::multi_index_container;

View File

@ -73,7 +73,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
using namespace libtorrent;
using namespace boost::posix_time;
using boost::tuples::tuple;
using boost::tuples::get;
using boost::tuples::make_tuple;
@ -82,47 +81,6 @@ using boost::bind;
using boost::mutex;
using libtorrent::aux::session_impl;
// PROFILING CODE
#ifdef TORRENT_PROFILE
#include <boost/date_time/posix_time/ptime.hpp>
namespace libtorrent
{
namespace
{
using ptime;
using time_duration;
using boost::posix_time::microsec_clock;
std::vector<std::pair<ptime, std::string> > checkpoints;
}
void add_checkpoint(std::string const& str)
{
checkpoints.push_back(std::make_pair(microsec_clock::universal_time(), str));
}
void print_checkpoints()
{
for (std::vector<std::pair<ptime, std::string> >::iterator i
= checkpoints.begin(); i != checkpoints.end(); ++i)
{
ptime cur = i->first;
if (i + 1 != checkpoints.end())
{
time_duration diff = (i + 1)->first - cur;
std::cout << diff.total_microseconds() << " " << i->second << "\n";
}
else
{
std::cout << " " << i->second << "\n";
}
}
}
}
#endif
namespace
{
@ -1332,8 +1290,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string now(to_simple_string(second_clock::local_time()));
(*m_ses.m_logger) << now << " resolving: " << url << "\n";
(*m_ses.m_logger) << time_now_string() << " resolving: " << url << "\n";
#endif
m_resolving_web_seeds.insert(url);
@ -1370,8 +1327,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string now(to_simple_string(second_clock::local_time()));
(*m_ses.m_logger) << now << " completed resolve proxy hostname for: " << url << "\n";
(*m_ses.m_logger) << time_now_string() << " completed resolve proxy hostname for: " << url << "\n";
#endif
if (e || host == tcp::resolver::iterator())
@ -1424,8 +1380,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string now(to_simple_string(second_clock::local_time()));
(*m_ses.m_logger) << now << " completed resolve: " << url << "\n";
(*m_ses.m_logger) << time_now_string() << " completed resolve: " << url << "\n";
#endif
std::set<std::string>::iterator i = m_resolving_web_seeds.find(url);
@ -2142,7 +2097,6 @@ namespace libtorrent
{
INVARIANT_CHECK;
using namespace boost::posix_time;
++m_currently_trying_tracker;
if ((unsigned)m_currently_trying_tracker >= m_trackers.size())

View File

@ -650,7 +650,6 @@ namespace libtorrent
boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
if (!t) throw_invalid_handle();
using boost::posix_time::second_clock;
t->force_tracker_request(time_now()
+ seconds(duration.total_seconds()));
}

View File

@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <boost/lexical_cast.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/next_prior.hpp>
#include <boost/bind.hpp>
@ -218,9 +217,6 @@ namespace
namespace libtorrent
{
using namespace boost::gregorian;
using namespace boost::posix_time;
// standard constructor that parses a torrent file
torrent_info::torrent_info(const entry& torrent_file)
: m_creation_date(pt::ptime(pt::not_a_date_time))
@ -642,9 +638,6 @@ namespace libtorrent
{
assert(m_piece_length > 0);
using namespace boost::gregorian;
using namespace boost::posix_time;
namespace fs = boost::filesystem;
if ((m_urls.empty() && m_nodes.empty()) || m_files.empty())

View File

@ -67,7 +67,6 @@ namespace
};
}
using namespace boost::posix_time;
using boost::bind;
using boost::lexical_cast;

View File

@ -39,13 +39,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/xml_parse.hpp"
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <asio/ip/host_name.hpp>
#include <asio/ip/multicast.hpp>
#include <boost/thread/mutex.hpp>
#include <cstdlib>
using boost::posix_time::microsec_clock;
using boost::bind;
using namespace libtorrent;
@ -110,7 +108,7 @@ void upnp::rebind(address const& listen_interface)
}
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " local ip: " << m_local_ip.to_string() << std::endl;
#endif
@ -182,7 +180,7 @@ void upnp::discover_device()
, this, _1)));
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " ==> Broadcasting search for rootdevice" << std::endl;
#endif
}
@ -218,12 +216,11 @@ void upnp::set_mappings(int tcp, int udp)
void upnp::resend_request(asio::error_code const& e)
{
using boost::posix_time::hours;
if (e) return;
if (m_retry_count >= 9)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " *** Got no response in 9 retries. Giving up, "
"disabling UPnP." << std::endl;
#endif
@ -237,7 +234,6 @@ void upnp::on_reply(asio::error_code const& e
, std::size_t bytes_transferred)
{
using namespace libtorrent::detail;
using boost::posix_time::seconds;
if (e) return;
// since we're using udp, send the query 4 times
@ -268,7 +264,7 @@ void upnp::on_reply(asio::error_code const& e
catch (std::exception& e)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice responded with incorrect HTTP packet: "
<< e.what() << ". Ignoring device" << std::endl;
#endif
@ -278,7 +274,7 @@ void upnp::on_reply(asio::error_code const& e
if (p.status_code() != 200)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice responded with HTTP status: " << p.status_code()
<< ". Ignoring device" << std::endl;
#endif
@ -288,7 +284,7 @@ void upnp::on_reply(asio::error_code const& e
if (!p.header_finished())
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice responded with incomplete HTTP "
"packet. Ignoring device" << std::endl;
#endif
@ -299,7 +295,7 @@ void upnp::on_reply(asio::error_code const& e
if (url.empty())
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice response is missing a location header. "
"Ignoring device" << std::endl;
#endif
@ -322,7 +318,7 @@ void upnp::on_reply(asio::error_code const& e
if (protocol != "http")
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice uses unsupported protocol: '" << protocol
<< "'. Ignoring device" << std::endl;
#endif
@ -332,14 +328,14 @@ void upnp::on_reply(asio::error_code const& e
if (d.port == 0)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice responded with a url with port 0. "
"Ignoring device" << std::endl;
#endif
return;
}
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Found rootdevice: " << d.url << std::endl;
#endif
@ -420,7 +416,7 @@ void upnp::map_port(rootdevice& d, int i)
post(d, soap, soap_action);
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " ==> AddPortMapping: " << soap.str() << std::endl;
#endif
@ -461,7 +457,7 @@ void upnp::unmap_port(rootdevice& d, int i)
post(d, soap, soap_action);
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " ==> DeletePortMapping: " << soap.str() << std::endl;
#endif
}
@ -535,7 +531,7 @@ void upnp::on_upnp_xml(asio::error_code const& e
if (e)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== error while fetching control url: " << e.message() << std::endl;
#endif
return;
@ -544,7 +540,7 @@ void upnp::on_upnp_xml(asio::error_code const& e
if (!p.header_finished())
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== incomplete http message" << std::endl;
#endif
return;
@ -566,7 +562,7 @@ void upnp::on_upnp_xml(asio::error_code const& e
}
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== Rootdevice response, found control URL: " << s.control_url << std::endl;
#endif
@ -612,7 +608,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
if (e)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== error while adding portmap: " << e.message() << std::endl;
#endif
m_devices.erase(d);
@ -641,7 +637,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
if (!p.header_finished())
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== incomplete http message" << std::endl;
#endif
m_devices.erase(d);
@ -655,7 +651,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
if (s.error_code != -1)
{
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== got error message: " << s.error_code << std::endl;
}
#endif
@ -697,7 +693,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
}
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== map response: " << std::string(p.get_body().begin, p.get_body().end)
<< std::endl;
#endif
@ -718,8 +714,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
d.mapping[mapping].expires = time_now()
+ seconds(int(d.lease_duration * 0.75f));
ptime next_expire = m_refresh_timer.expires_at();
if (next_expire == ptime(boost::date_time::not_a_date_time)
|| next_expire < time_now()
if (next_expire < time_now()
|| next_expire > d.mapping[mapping].expires)
{
m_refresh_timer.expires_at(d.mapping[mapping].expires);
@ -754,7 +749,7 @@ void upnp::on_upnp_unmap_response(asio::error_code const& e
if (e)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== error while deleting portmap: " << e.message() << std::endl;
#endif
}
@ -762,14 +757,14 @@ void upnp::on_upnp_unmap_response(asio::error_code const& e
if (!p.header_finished())
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== incomplete http message" << std::endl;
#endif
return;
}
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << to_simple_string(microsec_clock::universal_time())
m_log << time_now_string()
<< " <== unmap response: " << std::string(p.get_body().begin, p.get_body().end)
<< std::endl;
#endif

View File

@ -50,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/version.hpp"
#include "libtorrent/aux_/session_impl.hpp"
using namespace boost::posix_time;
using boost::bind;
using boost::shared_ptr;
using libtorrent::aux::session_impl;