Revision: 7477
http://libtorrent.svn.sourceforge.net/libtorrent/?rev=7477&view=rev
Author: arvidn
Date: 2012-09-28 00:22:32 +0000 (Fri, 28 Sep 2012)
Log Message:
-----------
merged changes from trunk
Modified Paths:
--------------
branches/libtorrent_aio/ChangeLog
branches/libtorrent_aio/examples/Makefile.am
branches/libtorrent_aio/include/libtorrent/aux_/session_impl.hpp
branches/libtorrent_aio/include/libtorrent/config.hpp
branches/libtorrent_aio/include/libtorrent/socket_type.hpp
branches/libtorrent_aio/include/libtorrent/torrent.hpp
branches/libtorrent_aio/include/libtorrent/tracker_manager.hpp
branches/libtorrent_aio/src/GeoIP.c
branches/libtorrent_aio/src/broadcast_socket.cpp
branches/libtorrent_aio/src/enum_net.cpp
branches/libtorrent_aio/src/file.cpp
branches/libtorrent_aio/src/http_tracker_connection.cpp
branches/libtorrent_aio/src/kademlia/dht_tracker.cpp
branches/libtorrent_aio/src/kademlia/routing_table.cpp
branches/libtorrent_aio/src/kademlia/rpc_manager.cpp
branches/libtorrent_aio/src/natpmp.cpp
branches/libtorrent_aio/src/session_impl.cpp
branches/libtorrent_aio/src/settings_pack.cpp
branches/libtorrent_aio/src/torrent.cpp
branches/libtorrent_aio/src/tracker_manager.cpp
branches/libtorrent_aio/src/udp_socket.cpp
branches/libtorrent_aio/src/udp_tracker_connection.cpp
branches/libtorrent_aio/src/utp_stream.cpp
Property Changed:
----------------
branches/libtorrent_aio/
Property changes on: branches/libtorrent_aio
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/RC_0_16:6640,6657,6662,6665,6669,6673-6675,6678,6684,6686,6688,6690,6692,6694-6695,6698,6700,6715,6936,6938,6946,6951,6956,6971,6974,6976,6979,7166,7200,7206,7258,7311,7314,7323,7333,7339,7348,7358,7371,7373,7375,7379,7395,7422,7433
/branches/libtorrent_aio_arc:6324-6529
/branches/libtorrent_aio_ghost_torrents:6532-7262
/branches/libtorrent_aio_peer_classes:6326-6856
/branches/libtorrent_aio_settings:6709-6880
/branches/libtorrent_utp:3973-5057
/branches/ssl:6336-6361
/trunk:4468-7436
+ /branches/RC_0_16:6640,6657,6662,6665,6669,6673-6675,6678,6684,6686,6688,6690,6692,6694-6695,6698,6700,6715,6936,6938,6946,6951,6956,6971,6974,6976,6979,7166,7200,7206,7258,7311,7314,7323,7333,7339,7348,7358,7371,7373,7375,7379,7395,7422,7433,7458,7461,7464,7466,7469,7471,7473
/branches/libtorrent_aio_arc:6324-6529
/branches/libtorrent_aio_ghost_torrents:6532-7262
/branches/libtorrent_aio_peer_classes:6326-6856
/branches/libtorrent_aio_settings:6709-6880
/branches/libtorrent_utp:3973-5057
/branches/ssl:6336-6361
/trunk:4468-7474
Modified: branches/libtorrent_aio/ChangeLog
===================================================================
--- branches/libtorrent_aio/ChangeLog 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/ChangeLog 2012-09-28 00:22:32 UTC (rev 7477)
@@ -21,6 +21,9 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
+ * raise the default number of torrents allowed to announce to trackers to 1600
+ * improve uTP slow start behavior
+ * fixed UDP socket error causing it to fail on Win7
* update use of boost.system to not use deprecated functions
* fix GIL issue in python bindings. Deprecated extension support in python
* fixed bug where setting upload slots to -1 would not mean infinite
Modified: branches/libtorrent_aio/examples/Makefile.am
===================================================================
--- branches/libtorrent_aio/examples/Makefile.am 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/examples/Makefile.am 2012-09-28 00:22:32 UTC (rev 7477)
@@ -6,7 +6,8 @@
simple_client \
rss_reader \
parse_request_log \
- utp_test
+ utp_test \
+ connection_tester
if ENABLE_EXAMPLES
bin_PROGRAMS = $(example_programs)
@@ -30,6 +31,9 @@
enum_if_SOURCES = enum_if.cpp
#enum_if_LDADD = $(top_builddir)/src/libtorrent-rasterbar.la
+connection_tester_SOURCES = connection_tester.cpp
+#connection_tester_LDADD = $(top_builddir)/src/libtorrent-rasterbar.la
+
rss_reader_SOURCES = rss_reader.cpp
#rss_reader_LDADD = $(top_builddir)/src/libtorrent-rasterbar.la
Modified: branches/libtorrent_aio/include/libtorrent/aux_/session_impl.hpp
===================================================================
--- branches/libtorrent_aio/include/libtorrent/aux_/session_impl.hpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/include/libtorrent/aux_/session_impl.hpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -1378,7 +1378,7 @@
void tracker_warning(tracker_request const& req
, std::string const& str)
{
- debug_log("*** tracker warning: " + str);
+ debug_log("*** tracker warning: %s", str.c_str());
}
void tracker_response(tracker_request const&
@@ -1409,7 +1409,7 @@
}
snprintf(tmp, 200, "external ip: %s\n", print_address(external_ip).c_str());
s += tmp;
- debug_log(s);
+ debug_log("%s", s.c_str());
}
void tracker_request_timed_out(
@@ -1422,15 +1422,23 @@
, int response_code, error_code const& ec, const std::string& str
, int retry_interval)
{
- char msg[256];
- snprintf(msg, sizeof(msg), "*** tracker error: %d: %s %s"
+ debug_log("*** tracker error: %d: %s %s"
, response_code, ec.message().c_str(), str.c_str());
- debug_log(msg);
}
- void debug_log(const std::string& line)
+ void debug_log(const char* fmt, ...) const
{
- (*m_ses.m_logger) << time_now_string() << " " << line << "\n";
+ if (!m_ses.m_logger) return;
+
+ va_list v;
+ va_start(v, fmt);
+
+ char usr[1024];
+ vsnprintf(usr, sizeof(usr), fmt, v);
+ va_end(v);
+ char buf[1280];
+ snprintf(buf, sizeof(buf), "%s: %s\n", time_now_string(), usr);
+ (*m_ses.m_logger) << buf;
}
session_impl& m_ses;
};
Modified: branches/libtorrent_aio/include/libtorrent/config.hpp
===================================================================
--- branches/libtorrent_aio/include/libtorrent/config.hpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/include/libtorrent/config.hpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -292,6 +292,18 @@
#define TORRENT_USE_IFADDRS 1
#define TORRENT_USE_IFCONF 1
+// ==== eCS(OS/2) ===
+#elif defined __OS2__
+#define TORRENT_OS2
+#define TORRENT_HAS_FALLOCATE 0
+#define TORRENT_USE_IFCONF 1
+#define TORRENT_USE_SYSCTL 1
+#define TORRENT_USE_MLOCK 0
+#define TORRENT_USE_IPV6 0
+#define TORRENT_ICONV_ARG (const char**)
+#define TORRENT_USE_WRITEV 0
+#define TORRENT_USE_READV 0
+
#else
#warning unknown OS, assuming BSD
#define TORRENT_BSD
Modified: branches/libtorrent_aio/include/libtorrent/socket_type.hpp
===================================================================
--- branches/libtorrent_aio/include/libtorrent/socket_type.hpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/include/libtorrent/socket_type.hpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -51,6 +51,10 @@
#include "libtorrent/debug.hpp"
#endif
+#if defined TORRENT_OS2 && defined ioc
+#undef ioc
+#endif
+
#if TORRENT_USE_I2P
#define TORRENT_SOCKTYPE_I2P_FORWARD(x) \
Modified: branches/libtorrent_aio/include/libtorrent/torrent.hpp
===================================================================
--- branches/libtorrent_aio/include/libtorrent/torrent.hpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/include/libtorrent/torrent.hpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -752,7 +752,7 @@
// LOGGING
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- virtual void debug_log(const std::string& line);
+ virtual void debug_log(const char* fmt, ...) const;
#endif
// DEBUG
Modified: branches/libtorrent_aio/include/libtorrent/tracker_manager.hpp
===================================================================
--- branches/libtorrent_aio/include/libtorrent/tracker_manager.hpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/include/libtorrent/tracker_manager.hpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -167,7 +167,7 @@
, int retry_interval) = 0;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- virtual void debug_log(const std::string& line) = 0;
+ virtual void debug_log(const char* fmt, ...) const = 0;
#else
private:
#endif
Modified: branches/libtorrent_aio/src/GeoIP.c
===================================================================
--- branches/libtorrent_aio/src/GeoIP.c 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/GeoIP.c 2012-09-28 00:22:32 UTC (rev 7477)
@@ -334,7 +334,7 @@
char const* src_start;
/* GeoIP Database file updated */
if (gi->flags & (GEOIP_MEMORY_CACHE | GEOIP_MMAP_CACHE)) {
-#ifndef WIN32
+#if !defined WIN32 && !defined __OS2__
if ( gi->flags & GEOIP_MMAP_CACHE) {
munmap(gi->cache, gi->size);
gi->cache = NULL;
@@ -371,7 +371,7 @@
gi->mtime = buf.st_mtime;
gi->size = buf.st_size;
-#ifndef WIN32
+#if !defined WIN32 && !defined __OS2__
if ( gi->flags & GEOIP_MMAP_CACHE) {
gi->cache = (unsigned char*)mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fileno(gi->GeoIPDatabase), 0);
if ( gi->cache == MAP_FAILED ) {
@@ -594,7 +594,7 @@
}
gi->mtime = buf.st_mtime;
gi->size = buf.st_size;
-#ifndef WIN32
+#if !defined WIN32 && !defined __OS2__
/* MMAP added my Peter Shipley */
if ( flags & GEOIP_MMAP_CACHE) {
gi->cache = (unsigned char*)mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fileno(gi->GeoIPDatabase), 0);
@@ -660,7 +660,7 @@
if (gi->GeoIPDatabase != NULL)
fclose(gi->GeoIPDatabase);
if (gi->cache != NULL) {
-#ifndef WIN32
+#if !defined WIN32 && !defined __OS2__
if ( gi->flags & GEOIP_MMAP_CACHE) {
munmap(gi->cache, gi->size);
} else
Modified: branches/libtorrent_aio/src/broadcast_socket.cpp
===================================================================
--- branches/libtorrent_aio/src/broadcast_socket.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/broadcast_socket.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -32,6 +32,11 @@
#include <boost/version.hpp>
+#include "libtorrent/config.hpp"
+#if defined TORRENT_OS2
+#include <pthread.h>
+#endif
+
#include <boost/bind.hpp>
#include "libtorrent/socket.hpp"
Modified: branches/libtorrent_aio/src/enum_net.cpp
===================================================================
--- branches/libtorrent_aio/src/enum_net.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/enum_net.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -88,6 +88,10 @@
#include <ifaddrs.h>
#endif
+#if defined(TORRENT_OS2) and !defined(IF_NAMESIZE)
+#define IF_NAMESIZE IFNAMSIZ
+#endif
+
namespace libtorrent { namespace
{
@@ -222,6 +226,9 @@
#endif
#if TORRENT_USE_SYSCTL
+#ifdef TORRENT_OS2
+int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
+#endif
bool parse_route(int s, rt_msghdr* rtm, ip_route* rt_info)
{
@@ -493,7 +500,11 @@
close(s);
return ret;
}
+#ifndef TORRENT_OS2
iface.mtu = req.ifr_mtu;
+#else
+ iface.mtu = req.ifr_metric; // according to tcp/ip reference
+#endif
memset(&req, 0, sizeof(req));
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE - 1);
@@ -762,7 +773,11 @@
int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_UNSPEC, NET_RT_DUMP, 0};
size_t needed = 0;
+#ifdef TORRENT_OS2
+ if (__libsocket_sysctl(mib, 6, 0, &needed, 0, 0) < 0)
+#else
if (sysctl(mib, 6, 0, &needed, 0, 0) < 0)
+#endif
{
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
@@ -780,7 +795,11 @@
return std::vector<ip_route>();
}
+#ifdef TORRENT_OS2
+ if (__libsocket_sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
+#else
if (sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
+#endif
{
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
Modified: branches/libtorrent_aio/src/file.cpp
===================================================================
--- branches/libtorrent_aio/src/file.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/file.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -514,7 +514,7 @@
{
while (*p != '/'
&& *p != '\0'
-#ifdef TORRENT_WINDOWS
+#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
&& *p != '\\'
#endif
) ++p;
@@ -568,7 +568,7 @@
{
if (f.empty()) return false;
-#ifdef TORRENT_WINDOWS
+#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
// match \\ form
if (f == "\\\\") return true;
int i = 0;
@@ -658,7 +658,7 @@
if (f.empty()) return "";
char const* first = f.c_str();
char const* sep = strrchr(first, '/');
-#ifdef TORRENT_WINDOWS
+#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
char const* altsep = strrchr(first, '\\');
if (sep == 0 || altsep > sep) sep = altsep;
#endif
@@ -673,7 +673,7 @@
{
--sep;
if (*sep == '/'
-#ifdef TORRENT_WINDOWS
+#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|| *sep == '\\'
#endif
)
@@ -692,7 +692,7 @@
if (lhs.empty() || lhs == ".") return rhs;
if (rhs.empty() || rhs == ".") return lhs;
-#ifdef TORRENT_WINDOWS
+#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
#define TORRENT_SEPARATOR "\\"
bool need_sep = lhs[lhs.size()-1] != '\\' && lhs[lhs.size()-1] != '/';
#else
@@ -883,7 +883,7 @@
bool is_complete(std::string const& f)
{
if (f.empty()) return false;
-#ifdef TORRENT_WINDOWS
+#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
int i = 0;
// match the xx:\ or xx:/ form
while (f[i] && is_alpha(f[i])) ++i;
@@ -1150,8 +1150,11 @@
if (mode & attribute_executable)
permissions |= S_IXGRP | S_IXOTH | S_IXUSR;
-
+#ifdef O_BINARY
+ static const int mode_array[] = {O_RDONLY | O_BINARY, O_WRONLY | O_CREAT | O_BINARY, O_RDWR | O_CREAT | O_BINARY};
+#else
static const int mode_array[] = {O_RDONLY, O_WRONLY | O_CREAT, O_RDWR | O_CREAT};
+#endif
#ifdef O_NOATIME
static const int no_atime_flag[] = {0, O_NOATIME};
Modified: branches/libtorrent_aio/src/http_tracker_connection.cpp
===================================================================
--- branches/libtorrent_aio/src/http_tracker_connection.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/http_tracker_connection.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -245,7 +245,7 @@
boost::shared_ptr<request_callback> cb = requester();
if (cb)
{
- cb->debug_log("==> TRACKER_REQUEST [ url: " + url + " ]");
+ cb->debug_log("==> TRACKER_REQUEST [ url: %s ]", url.c_str());
}
#endif
}
Modified: branches/libtorrent_aio/src/kademlia/dht_tracker.cpp
===================================================================
--- branches/libtorrent_aio/src/kademlia/dht_tracker.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/kademlia/dht_tracker.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -432,7 +432,14 @@
{
if (ec == asio::error::connection_refused
|| ec == asio::error::connection_reset
- || ec == asio::error::connection_aborted)
+ || ec == asio::error::connection_aborted
+#ifdef WIN32
+ || ec == error_code(ERROR_HOST_UNREACHABLE, get_system_category())
+ || ec == error_code(ERROR_PORT_UNREACHABLE, get_system_category())
+ || ec == error_code(ERROR_CONNECTION_REFUSED, get_system_category())
+ || ec == error_code(ERROR_CONNECTION_ABORTED, get_system_category())
+#endif
+ )
{
m_dht.unreachable(ep);
}
Modified: branches/libtorrent_aio/src/kademlia/routing_table.cpp
===================================================================
--- branches/libtorrent_aio/src/kademlia/routing_table.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/kademlia/routing_table.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -625,7 +625,10 @@
continue;
}
// this entry belongs in the new bucket
- new_bucket.push_back(*j);
+ if (int(new_bucket.size()) < bucket_size_limit)
+ new_bucket.push_back(*j);
+ else if (int(new_replacement_bucket.size()) < m_bucket_size)
+ new_replacement_bucket.push_back(*j);
j = b.erase(j);
}
@@ -648,7 +651,7 @@
// this entry belongs in the new bucket
if (int(new_bucket.size()) < new_bucket_size)
new_bucket.push_back(*j);
- else
+ else if (int(new_replacement_bucket.size()) < m_bucket_size)
new_replacement_bucket.push_back(*j);
}
j = rb.erase(j);
@@ -754,7 +757,12 @@
m_ips.erase(j->addr.to_v4().to_bytes());
b.erase(j);
- j = std::find_if(rb.begin(), rb.end(), boost::bind(&node_entry::pinged, _1) == true);
+ // sort by RTT first, to find the node with the lowest
+ // RTT that is pinged
+ std::sort(rb.begin(), rb.end()
+ , boost::bind(&node_entry::rtt, _1) < boost::bind(&node_entry::rtt, _2));
+
+ j = std::find_if(rb.begin(), rb.end(), boost::bind(&node_entry::pinged, _1));
if (j == rb.end()) j = rb.begin();
b.push_back(*j);
rb.erase(j);
@@ -895,17 +903,6 @@
if (int(l.size()) >= count)
l.resize(count);
}
-/*
-routing_table::iterator routing_table::begin() const
-{
- // +1 to avoid ourself
- return iterator(m_buckets.begin() + 1, m_buckets.end());
-}
-routing_table::iterator routing_table::end() const
-{
- return iterator(m_buckets.end(), m_buckets.end());
-}
-*/
} } // namespace libtorrent::dht
Modified: branches/libtorrent_aio/src/kademlia/rpc_manager.cpp
===================================================================
--- branches/libtorrent_aio/src/kademlia/rpc_manager.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/kademlia/rpc_manager.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -376,8 +376,8 @@
{
INVARIANT_CHECK;
- const static int short_timeout = 3;
- const static int timeout = 20;
+ const static int short_timeout = 2;
+ const static int timeout = 10;
// look for observers that have timed out
Modified: branches/libtorrent_aio/src/natpmp.cpp
===================================================================
--- branches/libtorrent_aio/src/natpmp.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/natpmp.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -29,6 +29,10 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include "libtorrent/config.hpp"
+#if defined TORRENT_OS2
+#include <pthread.h>
+#endif
#include "libtorrent/pch.hpp"
Modified: branches/libtorrent_aio/src/session_impl.cpp
===================================================================
--- branches/libtorrent_aio/src/session_impl.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/session_impl.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -2667,6 +2667,12 @@
if (ec != asio::error::operation_aborted
&& m_alerts.should_post<udp_error_alert>())
m_alerts.post_alert(udp_error_alert(ep, ec));
+
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
+ char msg[200];
+ snprintf(msg, sizeof(msg), "UDP socket error: (%d) %s", ec.value(), ec.message().c_str());
+ (*m_logger) << msg << "\n";
+#endif
}
return false;
}
@@ -4386,14 +4392,14 @@
--hard_limit;
--type_limit;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- t->log_to_all_peers(("AUTO MANAGER STARTING TORRENT: " + t->torrent_file().name()).c_str());
+ t->log_to_all_peers("AUTO MANAGER STARTING TORRENT");
#endif
t->set_allow_peers(true);
}
else
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- t->log_to_all_peers(("AUTO MANAGER PAUSING TORRENT: " + t->torrent_file().name()).c_str());
+ t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT");
#endif
// use graceful pause for auto-managed torrents
t->set_allow_peers(false, true);
Modified: branches/libtorrent_aio/src/settings_pack.cpp
===================================================================
--- branches/libtorrent_aio/src/settings_pack.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/settings_pack.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -223,7 +223,7 @@
SET(active_downloads, 3, &session_impl::reset_auto_manage_timer),
SET(active_seeds, 5, &session_impl::reset_auto_manage_timer),
SET(active_dht_limit, 88, 0),
- SET(active_tracker_limit, 360, 0),
+ SET(active_tracker_limit, 1600, 0),
SET(active_lsd_limit, 60, 0),
SET(active_limit, 15, &session_impl::reset_auto_manage_timer),
SET_NOPREV(active_loaded_limit, 0, &session_impl::reset_auto_manage_timer),
Modified: branches/libtorrent_aio/src/torrent.cpp
===================================================================
--- branches/libtorrent_aio/src/torrent.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/torrent.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -400,16 +400,16 @@
error_code ec;
lazy_entry tmp;
lazy_entry const* info = 0;
-#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " adding magnet link with resume data\n";
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("adding magnet link with resume data");
#endif
if (lazy_bdecode(&(*p.resume_data)[0], &(*p.resume_data)[0]
+ p.resume_data->size(), tmp, ec, &pos) == 0
&& tmp.type() == lazy_entry::dict_t
&& (info = tmp.dict_find_dict("info")))
{
-#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " found metadata in resume data\n";
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("found metadata in resume data");
#endif
// verify the info-hash of the metadata stored in the resume file matches
// the torrent we're loading
@@ -421,36 +421,36 @@
// torrent, but the hash of the URL, until we have the full torrent
if (resume_ih == info_hash || !p.url.empty())
{
-#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " info-hash matched\n";
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("info-hash matched");
#endif
m_torrent_file = (p.ti ? p.ti : new torrent_info(resume_ih));
if (!m_torrent_file->parse_info_section(*info, ec, 0))
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " failed to load metadata from resume file: "
- << ec.message() << "\n";
+ debug_log("failed to load metadata from resume file: %s"
+ , ec.message().c_str());
#endif
}
-#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
else
{
- (*m_ses.m_logger) << time_now_string() << " successfully loaded metadata from resume file\n";
+ debug_log("successfully loaded metadata from resume file");
}
#endif
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
else
{
- (*m_ses.m_logger) << time_now_string() << " metadata info-hash failed\n";
+ debug_log("metadata info-hash failed");
}
#endif
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
else
{
- (*m_ses.m_logger) << time_now_string() << " no metadata found\n";
+ debug_log("no metadata found");
}
#endif
}
@@ -475,8 +475,7 @@
TORRENT_ASSERT(m_ses.is_single_thread());
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " creating torrent: "
- << torrent_file().name() << "\n";
+ debug_log("creating torrent: %s", torrent_file().name().c_str());
#endif
if (p.file_priorities)
m_file_priority = *p.file_priorities;
@@ -694,7 +693,6 @@
m_override_resume_data = true;
init();
- start_announcing();
}
#else
@@ -808,7 +806,6 @@
m_override_resume_data = true;
init();
- start_announcing();
}
#endif
@@ -816,9 +813,8 @@
void torrent::start()
{
TORRENT_ASSERT(m_ses.is_single_thread());
-#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " starting torrent: "
- << torrent_file().name() << "\n";
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("starting torrent");
#endif
TORRENT_ASSERT(!m_picker);
@@ -835,9 +831,7 @@
{
m_resume_data.reset();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " fastresume data for "
- << torrent_file().name() << " rejected: " << ec.message()
- << " pos: " << pos << "\n";
+ debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos);
#endif
if (m_ses.m_alerts.should_post<fastresume_rejected_alert>())
m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle(), ec, "", 0));
@@ -1105,10 +1099,8 @@
if (!j->error) return;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << "disk error: '" << j->error.ec.message()
- << " in file " << j->error.file
- << " in torrent " << torrent_file().name()
- << "\n";
+ debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str()
+ , resolve_filename(j->error.file).c_str());
#endif
TORRENT_ASSERT(j->piece >= 0);
@@ -1472,10 +1464,9 @@
}
}
-#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
- (*m_ses.m_logger) << time_now_string() << " <== INCOMING SSL CONNECTION [ torrent: "
- << m_torrent_file->name() << " | n: " << names << " | match: " << (match?"yes":"no")
- << " ]\n";
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]"
+ , names.c_str(), match?"yes":"no");
return match;
#endif
@@ -1719,9 +1710,8 @@
if (ev)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " fastresume data for "
- << torrent_file().name() << " rejected: "
- << error_code(ev, get_libtorrent_category()).message() << "\n";
+ debug_log("fastresume data rejected: %s"
+ , error_code(ev, get_libtorrent_category()).message().c_str());
#endif
m_resume_data.reset();
}
@@ -2060,10 +2050,16 @@
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " fastresume data for "
- << torrent_file().name() << " rejected: "
- << j->error.ec.message() << " ret:" << j->ret << "\n";
+ if (j->ret != 0)
+ {
+ debug_log("fastresume data rejected: ret: %d (%d) %s"
+ , j->ret, j->error.ec.value(), j->error.ec.message().c_str());
+ }
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ else
+ debug_log("fastresume data accepted");
#endif
+#endif
// if ret != 0, it means we need a full check. We don't necessarily need
// that when the resume data check fails. For instance, if the resume data
@@ -2310,10 +2306,7 @@
resolve_filename(j->error.file), j->error.operation_str(), get_handle()));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << ": fatal disk error ["
- " error: " << j->error.ec.message() <<
- " torrent: " << torrent_file().name() <<
- " ]\n";
+ debug_log("fatal disk error: (%d) %s", j->error.ec.value(), j->error.ec.message().c_str());
#endif
pause();
set_error(j->error.ec, j->error.file);
@@ -2497,13 +2490,25 @@
TORRENT_ASSERT(m_ses.is_single_thread());
INVARIANT_CHECK;
- if (m_trackers.empty()) return;
+ if (m_trackers.empty())
+ {
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("*** announce_with_tracker: no trackers");
+#endif
+ return;
+ }
if (m_abort) e = tracker_request::stopped;
// if we're not announcing to trackers, only allow
// stopping
- if (e != tracker_request::stopped && !m_announce_to_trackers) return;
+ if (e != tracker_request::stopped && !m_announce_to_trackers)
+ {
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("*** announce_with_tracker: event != stopped && !m_announce_to_trackers");
+#endif
+ return;
+ }
TORRENT_ASSERT(m_allow_peers || e == tracker_request::stopped);
@@ -2649,10 +2654,12 @@
}
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " ==> TACKER REQUEST " << req.url
- << " event=" << (req.event==tracker_request::stopped?"stopped"
+ debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d"
+ , req.url.c_str()
+ , (req.event==tracker_request::stopped?"stopped"
:req.event==tracker_request::started?"started":"")
- << " abort=" << m_abort << "\n";
+ , m_abort);
+
if (m_abort)
{
boost::shared_ptr<aux::tracker_logger> tl(new aux::tracker_logger(m_ses));
@@ -2661,8 +2668,11 @@
}
else
#endif
- m_ses.m_tracker_manager.queue_request(m_ses.m_io_service, m_ses.m_half_open, req
- , tracker_login() , shared_from_this());
+ {
+ m_ses.m_tracker_manager.queue_request(m_ses.m_io_service, m_ses.m_half_open, req
+ , tracker_login() , shared_from_this());
+ }
+
ae.updating = true;
ae.next_announce = now + seconds(20);
ae.min_announce = now + seconds(10);
@@ -2811,7 +2821,7 @@
std::copy(tracker_ips.begin(), tracker_ips.end(), std::ostream_iterator<address>(s, " "));
s << "\n";
s << "we connected to: " << tracker_ip << "\n";
- debug_log(s.str());
+ debug_log("%s", s.str().c_str());
#endif
// for each of the peers we got from the tracker
for (std::vector<peer_entry>::iterator i = peer_list.begin();
@@ -2909,8 +2919,8 @@
:m_ses.m_ipv4_interface.address();
announce_with_tracker(r.event, bind_interface);
#if (defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING) && TORRENT_USE_IOSTREAM
- debug_log("announce again using " + print_address(bind_interface)
- + " as the bind interface");
+ debug_log("announce again using %s as the bind interface"
+ , print_address(bind_interface).c_str());
#endif
}
}
@@ -2979,7 +2989,7 @@
#if defined TORRENT_LOGGING
if (ec)
- *m_ses.m_logger << time_now_string() << " on_i2p_resolve: " << ec.message() << "\n";
+ debug_log("i2p_resolve error: %s", ec.message().c_str());
#endif
if (ec || m_ses.is_aborted()) return;
@@ -3000,7 +3010,7 @@
#if defined TORRENT_LOGGING
if (e)
- *m_ses.m_logger << time_now_string() << " on_peer_name_lookup: " << e.message() << "\n";
+ debug_log("peer name lookup error: %s", e.message().c_str());
#endif
if (e || host == tcp::resolver::iterator() ||
m_ses.is_aborted()) return;
@@ -3010,7 +3020,7 @@
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
error_code ec;
- debug_log("blocked ip from tracker: " + host->endpoint().address().to_string(ec));
+ debug_log("blocked ip from tracker: %s", host->endpoint().address().to_string(ec).c_str());
#endif
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
m_ses.m_alerts.post_alert(peer_blocked_alert(get_handle(), host->endpoint().address()));
@@ -3357,11 +3367,11 @@
// -2: piece failed check
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " *** PIECE_FINISHED [ p: "
- << j->piece << " chk: " << ((ret == 0)
+ debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]"
+ , index, ((ret == 0)
?"passed":ret == -1
- ?"disk failed":"failed") << " size: "
- << m_torrent_file->piece_size(j->piece) << " ]\n";
+ ?"disk failed":"failed")
+ , m_torrent_file->piece_size(j->piece));
#endif
TORRENT_ASSERT(valid_metadata());
@@ -3797,12 +3807,11 @@
if (p->connection)
{
#ifdef TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " *** BANNING PEER [ " << p->ip()
- << " ] 'too many corrupt pieces'\n";
+ debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces"
+ , print_endpoint(p->ip()).c_str());
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
- (*p->connection->m_logger) << "*** BANNING PEER [ " << p->ip()
- << " ] 'too many corrupt pieces'\n";
+ p->connection->peer_log("*** BANNING PEER: Too many corrupt pieces");
#endif
p->connection->disconnect(errors::too_many_corrupt_pieces);
}
@@ -5040,7 +5049,7 @@
return;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " resolving web seed: " << web->url << "\n";
+ debug_log("resolving web seed: %s", web->url.c_str());
#endif
std::string protocol;
@@ -5054,8 +5063,8 @@
if (ec)
{
-#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " failed to parse web seed url: " << ec.message() << "\n";
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
+ debug_log("failed to parse web seed url: %s", ec.message().c_str());
#endif
if (m_ses.m_alerts.should_post<url_seed_alert>())
{
@@ -5070,7 +5079,7 @@
if (web->peer_info.banned)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << "banned web seed: " << web->url << "\n";
+ debug_log("banned web seed: %s", web->url.c_str());
#endif
if (m_ses.m_alerts.should_post<url_seed_alert>())
{
@@ -5176,16 +5185,18 @@
TORRENT_ASSERT(web->resolving == true);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " completed resolve proxy hostname for: " << web->url << "\n";
+ debug_log("completed resolve proxy hostname for: %s", web->url.c_str());
+#endif
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
if (e)
- *m_ses.m_logger << time_now_string() << " on_proxy_name_lookup: " << e.message() << "\n";
+ debug_log("proxy name lookup error: %s", e.message().c_str());
#endif
web->resolving = false;
if (web->removed)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " removed web seed\n";
+ debug_log("removed web seed");
#endif
remove_web_seed(web);
return;
@@ -5264,13 +5275,13 @@
TORRENT_ASSERT(web->resolving == true);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " completed resolve: " << web->url << "\n";
+ debug_log("completed resolve: %s", web->url.c_str());
#endif
web->resolving = false;
if (web->removed)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " removed web seed\n";
+ debug_log("removed web seed");
#endif
remove_web_seed(web);
return;
@@ -5283,8 +5294,8 @@
if (m_ses.m_alerts.should_post<url_seed_alert>())
m_ses.m_alerts.post_alert(url_seed_alert(get_handle(), web->url, e));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << web->url
- << " " << e.message() << "\n";
+ debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s"
+ , web->url.c_str(), e.value(), e.message().c_str());
#endif
// unavailable, retry in 30 minutes
@@ -5431,7 +5442,7 @@
web->peer_info.prev_amount_download = 0;
web->peer_info.prev_amount_upload = 0;
#if defined TORRENT_VERBOSE_LOGGING
- (*m_ses.m_logger) << time_now_string() << " web seed connection started " << web->url << "\n";
+ debug_log("web seed connection started: %s", web->url.c_str());
#endif
c->start();
@@ -5448,7 +5459,7 @@
TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << e.what() << "\n";
+ debug_log("*** HOST NAME LOOKUP FAILED: %s", e.what());
#endif
c->disconnect(errors::no_error, 1);
}
@@ -5587,7 +5598,8 @@
// unknown country!
p->set_country("!!");
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << "IP " << p->remote().address() << " was mapped to unknown country: " << country << "\n";
+ debug_log("IP \"%s\" was mapped to unknown country: %d"
+ , print_address(p->remote().address()).c_str(), country);
#endif
return;
}
@@ -6603,8 +6615,8 @@
if (!m_policy.new_connection(*p, m_ses.session_time()))
{
#if defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " CLOSING CONNECTION "
- << p->remote() << " policy::new_connection returned false (i.e. peer list full)\n";
+ debug_log("CLOSING CONNECTION \"%s\" peer list full"
+ , print_endpoint(p->remote()).c_str());
#endif
p->disconnect(errors::too_many_connections);
return false;
@@ -6616,8 +6628,8 @@
TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e;
#if defined TORRENT_LOGGING
- (*m_ses.m_logger) << time_now_string() << " CLOSING CONNECTION "
- << p->remote() << " policy::new_connection threw: " << e.what() << "\n";
+ debug_log("CLOSING CONNECTION \"%s\" caught exception: %s"
+ , print_endpoint(p->remote()).c_str(), e.what());
#endif
p->disconnect(errors::no_error);
return false;
@@ -6730,7 +6742,7 @@
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
- (*p->m_logger) << "*** CLOSING CONNECTION: " << ec.message() << "\n";
+ p->peer_log("*** CLOSING CONNECTION \"%s\"", ec.message().c_str());
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
std::size_t size = m_connections.size();
@@ -6857,7 +6869,7 @@
if (p->upload_only())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
- (*p->m_logger) << "*** SEED, CLOSING CONNECTION\n";
+ p->peer_log("*** SEED, CLOSING CONNECTION");
#endif
seeds.push_back(p);
}
@@ -6982,7 +6994,13 @@
TORRENT_ASSERT(m_ses.is_single_thread());
TORRENT_ASSERT(m_torrent_file->is_valid());
- if (m_abort) return;
+ if (m_abort)
+ {
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("files_checked(), paused");
+#endif
+ return;
+ }
// we might be finished already, in which case we should
// not switch to downloading mode. If all files are
@@ -7925,7 +7943,7 @@
}
#endif
- (*m_ses.m_logger) << time_now_string() << " " << message << "\n";
+ debug_log("%s", message);
}
#endif
@@ -8090,11 +8108,23 @@
void torrent::start_announcing()
{
TORRENT_ASSERT(m_ses.is_single_thread());
- if (is_paused()) return;
+ if (is_paused())
+ {
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("start_announcing(), paused");
+#endif
+ return;
+ }
// if we don't have metadata, we need to announce
// before checking files, to get peers to
// request the metadata from
- if (!m_files_checked && valid_metadata()) return;
+ if (!m_files_checked && valid_metadata())
+ {
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("start_announcing(), files not checked (with valid metadata)");
+#endif
+ return;
+ }
if (m_announcing) return;
m_announcing = true;
@@ -8745,7 +8775,7 @@
TORRENT_ASSERT(i->resolving == false);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
- (*m_ses.m_logger) << time_now_string() << " disconnect_web_seed: " << i->url << "\n";
+ debug_log("disconnect web seed: \"%s\"", i->url.c_str());
#endif
TORRENT_ASSERT(i->peer_info.connection);
i->peer_info.connection = 0;
@@ -9046,8 +9076,11 @@
m_state = s;
+#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
+ debug_log("set_state() %d", m_state);
+#endif
+
update_want_peers();
-
state_updated();
#ifndef TORRENT_DISABLE_EXTENSIONS
@@ -9357,7 +9390,7 @@
INVARIANT_CHECK;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- debug_log("*** tracker error: " + ec.message() + " " + msg);
+ debug_log("*** tracker error: (%d) %s %s", ec.value(), ec.message().c_str(), msg.c_str());
#endif
if (r.kind == tracker_request::announce_request)
{
@@ -9369,8 +9402,7 @@
ae->message = msg;
int tracker_index = ae - &m_trackers[0];
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- debug_log("*** increment tracker fail count ["
- + std::string(to_string(ae->fails).elems) + "]");
+ debug_log("*** increment tracker fail count [%d]", ae->fails);
#endif
deprioritize_tracker(tracker_index);
}
@@ -9395,10 +9427,21 @@
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
- void torrent::debug_log(const std::string& line)
+ void torrent::debug_log(const char* fmt, ...) const
{
TORRENT_ASSERT(m_ses.is_single_thread());
- (*m_ses.m_logger) << time_now_string() << " " << line << "\n";
+ if (!m_ses.m_logger) return;
+
+ va_list v;
+ va_start(v, fmt);
+
+ char usr[1024];
+ vsnprintf(usr, sizeof(usr), fmt, v);
+ va_end(v);
+ char buf[1280];
+ snprintf(buf, sizeof(buf), "%s: %s: %s\n", time_now_string()
+ , to_hex(info_hash().to_string()).substr(0, 6).c_str(), usr);
+ (*m_ses.m_logger) << buf;
}
#endif
Modified: branches/libtorrent_aio/src/tracker_manager.cpp
===================================================================
--- branches/libtorrent_aio/src/tracker_manager.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/tracker_manager.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -325,7 +325,7 @@
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
boost::shared_ptr<request_callback> rc = c->requester();
- if (rc) rc->debug_log("aborting: " + req.url);
+ if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif
}
l.unlock();
Modified: branches/libtorrent_aio/src/udp_socket.cpp
===================================================================
--- branches/libtorrent_aio/src/udp_socket.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/udp_socket.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -382,9 +382,17 @@
&& e != asio::error::connection_refused
&& e != asio::error::connection_aborted
&& e != asio::error::operation_aborted
+ && e != asio::error::network_reset
+ && e != asio::error::network_unreachable
#ifdef WIN32
// ERROR_MORE_DATA means the same thing as EMSGSIZE
&& e != error_code(ERROR_MORE_DATA, get_system_category())
+ && e != error_code(ERROR_HOST_UNREACHABLE, get_system_category())
+ && e != error_code(ERROR_PORT_UNREACHABLE, get_system_category())
+ && e != error_code(ERROR_RETRY, get_system_category())
+ && e != error_code(ERROR_NETWORK_UNREACHABLE, get_system_category())
+ && e != error_code(ERROR_CONNECTION_REFUSED, get_system_category())
+ && e != error_code(ERROR_CONNECTION_ABORTED, get_system_category())
#endif
&& e != asio::error::message_size)
{
Modified: branches/libtorrent_aio/src/udp_tracker_connection.cpp
===================================================================
--- branches/libtorrent_aio/src/udp_tracker_connection.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/udp_tracker_connection.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -121,7 +121,8 @@
&udp_tracker_connection::name_lookup, self(), _1, _2));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
- if (cb) cb->debug_log(("*** UDP_TRACKER [ initiating name lookup: " + hostname + " ]").c_str());
+ if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]"
+ , hostname.c_str());
#endif
}
@@ -173,7 +174,8 @@
if (m_ses.m_ip_filter.access(k->address()) == ip_filter::blocked)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
- if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: " + print_address(k->address()) + " ]");
+ if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: %s ]"
+ , print_address(k->address()).c_str());
#endif
k = m_endpoints.erase(k);
}
@@ -259,9 +261,7 @@
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
boost::shared_ptr<request_callback> cb = requester();
- char msg[200];
- snprintf(msg, 200, "*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
- if (cb) cb->debug_log(msg);
+ if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
#endif
m_abort = true;
fail(error_code(errors::timed_out));
@@ -303,9 +303,7 @@
boost::shared_ptr<request_callback> cb = requester();
if (cb)
{
- char msg[200];
- snprintf(msg, 200, "<== UDP_TRACKER_PACKET [ size: %d ]", size);
- cb->debug_log(msg);
+ cb->debug_log("<== UDP_TRACKER_PACKET [ size: %d ]", size);
}
#endif
@@ -319,9 +317,7 @@
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
if (cb)
{
- char msg[200];
- snprintf(msg, 200, "*** UDP_TRACKER_PACKET [ action: %d ]", action);
- cb->debug_log(msg);
+ cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action);
}
#endif
@@ -342,10 +338,8 @@
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
if (cb)
{
- char msg[200];
- snprintf(msg, 200, "*** UDP_TRACKER_RESPONSE [ tid: %x ]"
+ cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]"
, int(transaction));
- cb->debug_log(msg);
}
#endif
@@ -395,9 +389,7 @@
{
char hex_ih[41];
to_hex((char const*)&tracker_req().info_hash[0], 20, hex_ih);
- char msg[200];
- snprintf(msg, 200, "==> UDP_TRACKER_CONNECT [%s]", hex_ih);
- cb->debug_log(msg);
+ cb->debug_log("==> UDP_TRACKER_CONNECT [%s]", hex_ih);
}
#endif
if (m_abort) return;
@@ -498,9 +490,7 @@
if (cb)
{
boost::shared_ptr<request_callback> cb = requester();
- char msg[200];
- snprintf(msg, 200, "<== UDP_TRACKER_RESPONSE [ url: %s ]", tracker_req().url.c_str());
- cb->debug_log(msg);
+ cb->debug_log("<== UDP_TRACKER_RESPONSE [ url: %s ]", tracker_req().url.c_str());
}
#endif
@@ -660,9 +650,7 @@
{
char hex_ih[41];
to_hex((char const*)&req.info_hash[0], 20, hex_ih);
- char msg[200];
- snprintf(msg, 200, "==> UDP_TRACKER_ANNOUNCE [%s]", hex_ih);
- cb->debug_log(msg);
+ cb->debug_log("==> UDP_TRACKER_ANNOUNCE [%s]", hex_ih);
}
#endif
Modified: branches/libtorrent_aio/src/utp_stream.cpp
===================================================================
--- branches/libtorrent_aio/src/utp_stream.cpp 2012-09-28 00:20:36 UTC (rev 7476)
+++ branches/libtorrent_aio/src/utp_stream.cpp 2012-09-28 00:22:32 UTC (rev 7477)
@@ -3062,7 +3062,9 @@
if (m_slow_start)
{
- scaled_gain = (std::max)((window_factor * m_cwnd) >> 16, linear_gain);
+ // mimic TCP slow-start by adding the number of acked
+ // bytes to cwnd
+ scaled_gain = (std::max)(boost::int64_t(acked_bytes) << 16, linear_gain);
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|