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/operations.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/exception.hpp> #include <boost/filesystem/exception.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>

View File

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

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif #endif
#include <boost/filesystem/path.hpp> #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_container.hpp>
#include <boost/multi_index/member.hpp> #include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.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/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/date_time/time_duration.hpp>
#include <vector> #include <vector>
#include <string> #include <string>

View File

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

View File

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

View File

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

View File

@ -33,10 +33,21 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_TIME_HPP_INCLUDED #ifndef TORRENT_TIME_HPP_INCLUDED
#define TORRENT_TIME_HPP_INCLUDED #define TORRENT_TIME_HPP_INCLUDED
#include <ctime>
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#endif #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) #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> #include <boost/date_time/posix_time/posix_time.hpp>
@ -69,7 +80,6 @@ namespace libtorrent
#else #else
#include <asio/time_traits.hpp> #include <asio/time_traits.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
namespace libtorrent namespace libtorrent

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -296,10 +296,7 @@ namespace libtorrent { namespace dht
if (first) if (first)
{ {
first = false; first = false;
using boost::posix_time::to_simple_string; pc << "\n\n ***** starting log at " << time_now_string() << " *****\n\n"
using boost::posix_time::second_clock;
pc << "\n\n ***** starting log at " << to_simple_string(
second_clock::universal_time()) << " *****\n\n"
<< "minute:active nodes:passive nodes" << "minute:active nodes:passive nodes"
":ping replies sent:ping queries recvd:ping" ":ping replies sent:ping queries recvd:ping"
":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/lexical_cast.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp> #include <boost/filesystem/convenience.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
@ -72,9 +71,7 @@ namespace libtorrent { namespace
void log_timestamp() void log_timestamp()
{ {
using namespace boost::posix_time; m_file << time_now_string() << ": ";
std::string now(to_simple_string(second_clock::local_time()));
m_file << now << ": ";
} }
// can add entries to the extension handshake // can add entries to the extension handshake

View File

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

View File

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

View File

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

View File

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

View File

@ -73,7 +73,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/aux_/session_impl.hpp"
using namespace libtorrent; using namespace libtorrent;
using namespace boost::posix_time;
using boost::tuples::tuple; using boost::tuples::tuple;
using boost::tuples::get; using boost::tuples::get;
using boost::tuples::make_tuple; using boost::tuples::make_tuple;
@ -82,47 +81,6 @@ using boost::bind;
using boost::mutex; using boost::mutex;
using libtorrent::aux::session_impl; 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 namespace
{ {
@ -1332,8 +1290,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string now(to_simple_string(second_clock::local_time())); (*m_ses.m_logger) << time_now_string() << " resolving: " << url << "\n";
(*m_ses.m_logger) << now << " resolving: " << url << "\n";
#endif #endif
m_resolving_web_seeds.insert(url); m_resolving_web_seeds.insert(url);
@ -1370,8 +1327,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string now(to_simple_string(second_clock::local_time())); (*m_ses.m_logger) << time_now_string() << " completed resolve proxy hostname for: " << url << "\n";
(*m_ses.m_logger) << now << " completed resolve proxy hostname for: " << url << "\n";
#endif #endif
if (e || host == tcp::resolver::iterator()) if (e || host == tcp::resolver::iterator())
@ -1424,8 +1380,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string now(to_simple_string(second_clock::local_time())); (*m_ses.m_logger) << time_now_string() << " completed resolve: " << url << "\n";
(*m_ses.m_logger) << now << " completed resolve: " << url << "\n";
#endif #endif
std::set<std::string>::iterator i = m_resolving_web_seeds.find(url); std::set<std::string>::iterator i = m_resolving_web_seeds.find(url);
@ -2142,7 +2097,6 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
using namespace boost::posix_time;
++m_currently_trying_tracker; ++m_currently_trying_tracker;
if ((unsigned)m_currently_trying_tracker >= m_trackers.size()) 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(); boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
if (!t) throw_invalid_handle(); if (!t) throw_invalid_handle();
using boost::posix_time::second_clock;
t->force_tracker_request(time_now() t->force_tracker_request(time_now()
+ seconds(duration.total_seconds())); + seconds(duration.total_seconds()));
} }

View File

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

View File

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

View File

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