merged changes from RC_1_0
This commit is contained in:
parent
8833f27a46
commit
3f88389f05
|
@ -15,6 +15,7 @@ build_dirs:
|
|||
build_features:
|
||||
- ipv6=off
|
||||
- deprecated-functions=off
|
||||
- exception-handling=off
|
||||
- logging=verbose
|
||||
- statistics=on
|
||||
- asserts=off
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
* almost completely changed the storage interface (for custom storage)
|
||||
* added support for hashing pieces in multiple threads
|
||||
|
||||
* fix missing support for DHT put salt
|
||||
|
||||
1.0.1 release
|
||||
|
||||
* fix alignment issue in bitfield
|
||||
|
@ -93,6 +95,8 @@
|
|||
* fix uTP edge case where udp socket buffer fills up
|
||||
* fix nagle implementation in uTP
|
||||
|
||||
* disable optimistic disconnects when connection limit is low
|
||||
* improved error handling of session::listen_on
|
||||
* suppress initial 'completed' announce to trackers added with replace_trackers
|
||||
after becoming a seed
|
||||
* SOCKS4 fix for trying to connect over IPv6
|
||||
|
|
|
@ -31,6 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include <iterator>
|
||||
#include <stdio.h> // for snprintf
|
||||
#include <stdlib.h> // for atoi
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
|
|
|
@ -643,10 +643,12 @@ int snprintf(char* buf, int len, char const* fmt, ...)
|
|||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
#define TORRENT_TRY if (true)
|
||||
#define TORRENT_CATCH(x) else if (false)
|
||||
#define TORRENT_CATCH_ALL else if (false)
|
||||
#define TORRENT_DECLARE_DUMMY(x, y) x y
|
||||
#else
|
||||
#define TORRENT_TRY try
|
||||
#define TORRENT_CATCH(x) catch(x)
|
||||
#define TORRENT_CATCH_ALL catch(...)
|
||||
#define TORRENT_DECLARE_DUMMY(x, y)
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define ED25519_HPP
|
||||
|
||||
#include "libtorrent/export.hpp" // for TORRENT_EXPORT
|
||||
#include <stddef.h> // for size_t
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
|
||||
|
@ -37,11 +38,11 @@ namespace libtorrent
|
|||
invariant_checker_impl(T const& self_)
|
||||
: self(self_)
|
||||
{
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
check_invariant(self);
|
||||
}
|
||||
catch (...)
|
||||
TORRENT_CATCH_ALL
|
||||
{
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
@ -49,11 +50,11 @@ namespace libtorrent
|
|||
|
||||
~invariant_checker_impl()
|
||||
{
|
||||
try
|
||||
TORRENT_TRY
|
||||
{
|
||||
check_invariant(self);
|
||||
}
|
||||
catch (...)
|
||||
TORRENT_CATCH_ALL
|
||||
{
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
|
|
@ -80,11 +80,6 @@ sha1_hash TORRENT_EXTRA_EXPORT mutable_item_cas(
|
|||
, std::pair<char const*, int> salt
|
||||
, boost::uint64_t seq);
|
||||
|
||||
struct TORRENT_EXTRA_EXPORT invalid_item : std::exception
|
||||
{
|
||||
virtual const char* what() const throw() { return "invalid DHT item"; }
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
item_pk_len = 32,
|
||||
|
@ -102,8 +97,6 @@ public:
|
|||
, std::pair<char const*, int> salt
|
||||
, boost::uint64_t seq, char const* pk, char const* sk);
|
||||
item(lazy_entry const* v) { assign(v); }
|
||||
item(lazy_entry const* v, std::pair<char const*, int> salt
|
||||
, boost::uint64_t seq, char const* pk, char const* sig);
|
||||
|
||||
void assign(entry const& v)
|
||||
{
|
||||
|
|
|
@ -231,6 +231,10 @@ void get_item::put(std::vector<std::pair<node_entry, std::string> > const& v)
|
|||
a["k"] = std::string(m_data.pk().data(), item_pk_len);
|
||||
a["seq"] = m_data.seq();
|
||||
a["sig"] = std::string(m_data.sig().data(), item_sig_len);
|
||||
if (!m_data.salt().empty())
|
||||
{
|
||||
a["salt"] = m_data.salt();
|
||||
}
|
||||
}
|
||||
m_node.m_rpc.invoke(e, i->first.ep(), o);
|
||||
}
|
||||
|
|
|
@ -174,13 +174,6 @@ item::item(entry const& v
|
|||
assign(v, salt, seq, pk, sk);
|
||||
}
|
||||
|
||||
item::item(lazy_entry const* v, std::pair<char const*, int> salt
|
||||
, boost::uint64_t seq, char const* pk, char const* sig)
|
||||
{
|
||||
if (!assign(v, salt, seq, pk, sig))
|
||||
throw invalid_item();
|
||||
}
|
||||
|
||||
void item::assign(entry const& v, std::pair<char const*, int> salt
|
||||
, boost::uint64_t seq, char const* pk, char const* sk)
|
||||
{
|
||||
|
|
|
@ -2555,6 +2555,26 @@ retry:
|
|||
}
|
||||
}
|
||||
|
||||
if (m_listen_sockets.empty() && ec)
|
||||
{
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "cannot bind TCP listen socket to interface \"%s\": %s"
|
||||
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
||||
(*m_logger) << msg << "\n";
|
||||
#endif
|
||||
if (m_listen_port_retries > 0)
|
||||
{
|
||||
m_listen_interface.port(m_listen_interface.port() + 1);
|
||||
--m_listen_port_retries;
|
||||
goto retry;
|
||||
}
|
||||
if (m_alerts.should_post<listen_failed_alert>())
|
||||
m_alerts.post_alert(listen_failed_alert(print_endpoint(m_listen_interface)
|
||||
, listen_failed_alert::bind, ec, listen_failed_alert::udp));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 2 use bind_to_device in udp_socket
|
||||
m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec);
|
||||
if (ec)
|
||||
|
@ -2575,6 +2595,7 @@ retry:
|
|||
m_alerts.post_alert(listen_failed_alert(print_endpoint(m_listen_interface)
|
||||
, listen_failed_alert::bind, ec, listen_failed_alert::udp));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3805,40 +3826,50 @@ retry:
|
|||
{
|
||||
m_disconnect_time_scaler = m_settings.get_int(settings_pack::peer_turnover_interval);
|
||||
|
||||
if (num_connections() >= m_settings.get_int(settings_pack::connections_limit)
|
||||
* m_settings.get_int(settings_pack::peer_turnover_cutoff) / 100
|
||||
&& !m_torrents.empty())
|
||||
// if the connections_limit is too low, the disconnect
|
||||
// logic is disabled, since it is too disruptive
|
||||
if (m_settings.get_int(settings_pack::connections_limit) > 5)
|
||||
{
|
||||
// every 90 seconds, disconnect the worst peers
|
||||
// if we have reached the connection limit
|
||||
torrent_map::iterator i = std::max_element(m_torrents.begin(), m_torrents.end()
|
||||
, boost::bind(&torrent::num_peers, boost::bind(&torrent_map::value_type::second, _1))
|
||||
< boost::bind(&torrent::num_peers, boost::bind(&torrent_map::value_type::second, _2)));
|
||||
|
||||
TORRENT_ASSERT(i != m_torrents.end());
|
||||
int peers_to_disconnect = (std::min)((std::max)(
|
||||
int(i->second->num_peers() * m_settings.get_int(settings_pack::peer_turnover) / 100), 1)
|
||||
, i->second->num_connect_candidates());
|
||||
i->second->disconnect_peers(peers_to_disconnect
|
||||
, error_code(errors::optimistic_disconnect, get_libtorrent_category()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we haven't reached the global max. see if any torrent
|
||||
// has reached its local limit
|
||||
for (torrent_map::iterator i = m_torrents.begin()
|
||||
, end(m_torrents.end()); i != end; ++i)
|
||||
if (num_connections() >= m_settings.get_int(settings_pack::connections_limit)
|
||||
* m_settings.get_int(settings_pack::peer_turnover_cutoff) / 100
|
||||
&& !m_torrents.empty())
|
||||
{
|
||||
boost::shared_ptr<torrent> t = i->second;
|
||||
if (t->num_peers() < t->max_connections() * m_settings.get_int(settings_pack::peer_turnover_cutoff) / 100)
|
||||
continue;
|
||||
|
||||
int peers_to_disconnect = (std::min)((std::max)(int(i->second->num_peers()
|
||||
* m_settings.get_int(settings_pack::peer_turnover) / 100), 1)
|
||||
// every 90 seconds, disconnect the worst peers
|
||||
// if we have reached the connection limit
|
||||
torrent_map::iterator i = std::max_element(m_torrents.begin(), m_torrents.end()
|
||||
, boost::bind(&torrent::num_peers, boost::bind(&torrent_map::value_type::second, _1))
|
||||
< boost::bind(&torrent::num_peers, boost::bind(&torrent_map::value_type::second, _2)));
|
||||
|
||||
TORRENT_ASSERT(i != m_torrents.end());
|
||||
int peers_to_disconnect = (std::min)((std::max)(
|
||||
int(i->second->num_peers() * m_settings.get_int(settings_pack::peer_turnover) / 100), 1)
|
||||
, i->second->num_connect_candidates());
|
||||
t->disconnect_peers(peers_to_disconnect
|
||||
i->second->disconnect_peers(peers_to_disconnect
|
||||
, error_code(errors::optimistic_disconnect, get_libtorrent_category()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we haven't reached the global max. see if any torrent
|
||||
// has reached its local limit
|
||||
for (torrent_map::iterator i = m_torrents.begin()
|
||||
, end(m_torrents.end()); i != end; ++i)
|
||||
{
|
||||
boost::shared_ptr<torrent> t = i->second;
|
||||
|
||||
// ths disconnect logic is disabled for torrents with
|
||||
// too low connection limit
|
||||
if (t->num_peers() < t->max_connections()
|
||||
* m_settings.get_int(settings_pack::peer_turnover_cutoff) / 100
|
||||
|| t->max_connections() < 6)
|
||||
continue;
|
||||
|
||||
int peers_to_disconnect = (std::min)((std::max)(int(t->num_peers()
|
||||
* m_settings.get_int(settings_pack::peer_turnover) / 100), 1)
|
||||
, t->num_connect_candidates());
|
||||
t->disconnect_peers(peers_to_disconnect
|
||||
, error_code(errors::optimistic_disconnect, get_libtorrent_category()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -497,6 +497,11 @@ void udp_socket::setup_read(udp::socket* s)
|
|||
}
|
||||
TORRENT_CATCH(boost::system::system_error& e)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
// dummy
|
||||
error_code ec;
|
||||
boost::system::system_error e(ec);
|
||||
#endif
|
||||
get_io_service().post(boost::bind(&udp_socket::on_read
|
||||
, this, e.code(), s));
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/atomic.hpp>
|
||||
#include <list>
|
||||
#include "libtorrent/thread.hpp"
|
||||
#include "libtorrent/atomic.hpp"
|
||||
#include "test.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
|
@ -47,7 +47,7 @@ void fun(condition_variable* s, libtorrent::mutex* m, int* waiting, int i)
|
|||
fprintf(stderr, "thread %d done\n", i);
|
||||
}
|
||||
|
||||
void increment(condition_variable* s, libtorrent::mutex* m, int* waiting, atomic_count* c)
|
||||
void increment(condition_variable* s, libtorrent::mutex* m, int* waiting, boost::atomic<int>* c)
|
||||
{
|
||||
libtorrent::mutex::scoped_lock l(*m);
|
||||
*waiting += 1;
|
||||
|
@ -57,7 +57,7 @@ void increment(condition_variable* s, libtorrent::mutex* m, int* waiting, atomic
|
|||
++*c;
|
||||
}
|
||||
|
||||
void decrement(condition_variable* s, libtorrent::mutex* m, int* waiting, atomic_count* c)
|
||||
void decrement(condition_variable* s, libtorrent::mutex* m, int* waiting, boost::atomic<int>* c)
|
||||
{
|
||||
libtorrent::mutex::scoped_lock l(*m);
|
||||
*waiting += 1;
|
||||
|
@ -98,7 +98,7 @@ int test_main()
|
|||
threads.clear();
|
||||
|
||||
waiting = 0;
|
||||
atomic_count c(0);
|
||||
boost::atomic<int> c(0);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
threads.push_back(new thread(boost::bind(&increment, &cond, &m, &waiting, &c)));
|
||||
|
|
Loading…
Reference in New Issue