diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 0d0c447a2..08c781f48 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -44,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 45319aeb9..6ed02b8a6 100755 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -48,7 +48,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include diff --git a/include/libtorrent/file_pool.hpp b/include/libtorrent/file_pool.hpp index 01f161e21..bbb21e51b 100644 --- a/include/libtorrent/file_pool.hpp +++ b/include/libtorrent/file_pool.hpp @@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include -#include #include #include #include diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index 162cb36fa..78593c79d 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp index 589f62fbb..e823d8ff7 100755 --- a/include/libtorrent/http_tracker_connection.hpp +++ b/include/libtorrent/http_tracker_connection.hpp @@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include -#include #include #include diff --git a/include/libtorrent/lsd.hpp b/include/libtorrent/lsd.hpp index efb6ce2a7..09be0c9ed 100644 --- a/include/libtorrent/lsd.hpp +++ b/include/libtorrent/lsd.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/peer_id.hpp" -#include #include #include #include diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index f0f37484f..2f7f167a5 100755 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include diff --git a/include/libtorrent/time.hpp b/include/libtorrent/time.hpp index 6c524d3c3..02d0be35e 100644 --- a/include/libtorrent/time.hpp +++ b/include/libtorrent/time.hpp @@ -33,10 +33,21 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_TIME_HPP_INCLUDED #define TORRENT_TIME_HPP_INCLUDED +#include + #ifndef _WIN32 #include #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 @@ -69,7 +80,6 @@ namespace libtorrent #else #include -#include #include namespace libtorrent diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 6f8660717..e291384de 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include #include #include #include diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index be2c42eef..779f221a4 100755 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -41,8 +41,6 @@ POSSIBILITY OF SUCH DAMAGE. #pragma warning(push, 1) #endif -#include -#include #include #include #include diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 4e38f934d..9177e54a1 100755 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include -#include #include #include #include diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index bf87bea77..c0e6853b9 100755 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include -#include #include #ifdef _MSC_VER diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index a8ed22820..d5d045d0e 100755 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index af847c976..6dd35405d 100755 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -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); diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 3ffc9bf7b..cb3f2afc9 100755 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -86,8 +86,6 @@ namespace } -using namespace boost::posix_time; - namespace { bool url_has_argument(std::string const& url, std::string argument) diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index 501d68630..5d99d328a 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -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" diff --git a/src/logger.cpp b/src/logger.cpp index 62f581500..6881c5e7b 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #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 diff --git a/src/lsd.cpp b/src/lsd.cpp index 4f008b8b5..5fee68d58 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/xml_parse.hpp" #include #include -#include #include #include #include @@ -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()); diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 3be47aece..532fae6b4 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -37,9 +37,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include - -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; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 1688a6fa4..e76a56159 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -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 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 diff --git a/src/session.cpp b/src/session.cpp index 7d0ca8983..e2ccb3a84 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -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; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 3157c1db5..d64d35b68 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -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)); diff --git a/src/storage.cpp b/src/storage.cpp index d7379dfa5..f9fc3b795 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -48,7 +48,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include @@ -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; diff --git a/src/torrent.cpp b/src/torrent.cpp index 57c1f71d3..f8c7d7e56 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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 - -namespace libtorrent -{ - namespace - { - using ptime; - using time_duration; - using boost::posix_time::microsec_clock; - std::vector > 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 >::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::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()) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 12e2dd49e..a21e919ec 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -650,7 +650,6 @@ namespace libtorrent boost::shared_ptr 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())); } diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 8f419091d..22a95f76d 100755 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include -#include #include #include #include @@ -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()) diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index 6e7becb5b..d992ca050 100755 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -67,7 +67,6 @@ namespace }; } -using namespace boost::posix_time; using boost::bind; using boost::lexical_cast; diff --git a/src/upnp.cpp b/src/upnp.cpp index 924e504d0..859113254 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -39,13 +39,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/xml_parse.hpp" #include #include -#include #include #include #include #include -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 diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index c2b199de1..8bb40eef8 100755 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -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;