forked from premiere/premiere-libtorrent
Merge pull request #124 from arvidn/travis-build
attempt to fix travis OSX build
This commit is contained in:
commit
e50cf087ab
38
.travis.yml
38
.travis.yml
|
@ -2,14 +2,13 @@ language: cpp
|
|||
|
||||
os:
|
||||
- linux
|
||||
# - osx
|
||||
- osx
|
||||
|
||||
env:
|
||||
- variant=test_debug cc=gcc-cpp11 sim=1
|
||||
- variant=test_debug cc=clang-cpp11 sim=0
|
||||
- variant=test_debug cc=gcc-cpp98 sim=0
|
||||
- variant=test_release cc=gcc-cpp11 sim=0
|
||||
- variant=test_barebones cc=gcc-cpp11 sim=0
|
||||
- variant=test_debug lang=cpp11 sim=1
|
||||
- variant=test_debug lang=cpp98 sim=0
|
||||
- variant=test_release lang=cpp11 sim=0
|
||||
- variant=test_barebones lang=cpp11 sim=0
|
||||
|
||||
git:
|
||||
submodules: false
|
||||
|
@ -40,26 +39,37 @@ addons:
|
|||
|
||||
before_install:
|
||||
- git submodule update --init --recursive
|
||||
- if [ $TRAVIS_OS_NAME == "osx" ]; then brew install --quiet ccache boost-build boost-python; fi
|
||||
|
||||
# disable simulations on OSX for now. It hangs on travis
|
||||
- if [ $TRAVIS_OS_NAME == "osx" ]; then export toolset="darwin-${lang}"; export sim="0"; fi
|
||||
- if [ $TRAVIS_OS_NAME == "osx" ]; then export target="osx-tests"; fi
|
||||
- if [ $TRAVIS_OS_NAME == "linux" ]; then export toolset="gcc-${lang}"; fi
|
||||
- 'echo "using toolset: " ${toolset}'
|
||||
|
||||
install:
|
||||
- 'echo "using gcc : cpp11 : ccache g++-4.8 : <cflags>-std=c11 <cxxflags>-std=c++11 ;" > ~/user-config.jam'
|
||||
- 'echo "using gcc : cpp98 : ccache g++-4.8 : <cflags>-std=c99 <cxxflags>-std=c++98 ;" >> ~/user-config.jam'
|
||||
- 'echo "using clang : cpp11 : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 ;" >> ~/user-config.jam'
|
||||
- 'echo "using clang : cpp98 : ccache clang++ : <cflags>-std=c99 <cxxflags>-std=c++98 ;" >> ~/user-config.jam'
|
||||
|
||||
# osx builds need to disable the deprecated warning because of the openssl
|
||||
# shipping with the system having marked all functions as deprecated. Since
|
||||
# we're building with -Werror, we can't have those warnings
|
||||
- 'echo "using darwin : cpp11 : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>-Wno-deprecated-declarations ;" >> ~/user-config.jam'
|
||||
- 'echo "using darwin : cpp98 : ccache clang++ : <cflags>-std=c99 <cxxflags>-std=c++98 <compileflags>-Wno-deprecated-declarations ;" >> ~/user-config.jam'
|
||||
- 'echo "using python : 2.7 ;" >> ~/user-config.jam'
|
||||
- ccache -V && ccache --show-stats && ccache --zero-stats
|
||||
|
||||
script:
|
||||
- cd test
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant -l900 $CC
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant -l900 $toolset $target
|
||||
- cd ../examples
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant $CC
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset
|
||||
- cd ../bindings/python
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant $CC stage_module
|
||||
- LD_LIBRARY_PATH=. python test.py
|
||||
- if [ $sim ]; then
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset stage_module
|
||||
- LD_LIBRARY_PATH=. DYLD_LIBRARY_PATH=. python test.py
|
||||
- if [ $sim = "1" ]; then
|
||||
cd ../../simulation;
|
||||
bjam --hash -j3 crypto=built-in $CC;
|
||||
bjam --hash -j2 crypto=built-in $toolset;
|
||||
fi
|
||||
- ccache --show-stats
|
||||
|
||||
|
|
15
Jamfile
15
Jamfile
|
@ -186,11 +186,6 @@ rule linking ( properties * )
|
|||
result += <library>libiconv ;
|
||||
}
|
||||
|
||||
if <tcmalloc>yes in $(properties)
|
||||
{
|
||||
result += <library>tcmalloc ;
|
||||
}
|
||||
|
||||
if ( <toolset>gcc in $(properties)
|
||||
|| <toolset>clang in $(properties) )
|
||||
&& <target-os>linux in $(properties)
|
||||
|
@ -275,6 +270,10 @@ rule warnings ( properties * )
|
|||
result += <cflags>-Wno-exit-time-destructors ;
|
||||
result += <cflags>-Wno-documentation-unknown-command ;
|
||||
result += <cflags>-Wno-disabled-macro-expansion ;
|
||||
result += <cflags>-Wno-unused-command-line-argument ;
|
||||
result += <cflags>-Wno-error=implicit-fallthrough ;
|
||||
result += <cflags>-Wno-c++11-long-long ;
|
||||
result += <cflags>-Wno-variadic-macros ;
|
||||
|
||||
# in C++98 mode there's no way to silence this warning
|
||||
# in the code (without final)
|
||||
|
@ -296,8 +295,8 @@ rule warnings ( properties * )
|
|||
result += <cflags>-Wparentheses ;
|
||||
result += <cflags>-Wvla ;
|
||||
result += <cxxflags>-Wc++11-compat ;
|
||||
|
||||
result += <cflags>-Wno-format-zero-length ;
|
||||
result += <cflags>-Wno-long-long ;
|
||||
|
||||
# enable these warnings again, once the other ones are dealt with
|
||||
result += <cflags>-Wno-sign-compare ;
|
||||
|
@ -407,8 +406,6 @@ rule tag ( name : type ? : property-set )
|
|||
return $(name) ;
|
||||
}
|
||||
|
||||
feature tcmalloc : no yes : composite propagated link-incompatible ;
|
||||
|
||||
feature ipv6 : on off : composite propagated link-incompatible ;
|
||||
feature.compose <ipv6>off : <define>TORRENT_USE_IPV6=0 ;
|
||||
|
||||
|
@ -584,8 +581,6 @@ lib librt : : <name>rt <link>shared ;
|
|||
lib libsocket : : <use>libnsl <name>socket <link>shared <search>/usr/sfw/lib <link>shared ;
|
||||
lib libnsl : : <name>nsl <link>shared <search>/usr/sfw/lib <link>shared ;
|
||||
|
||||
lib tcmalloc : : <name>tcmalloc <link>shared ;
|
||||
|
||||
# socket libraries on windows
|
||||
lib wsock32 : : <name>wsock32 <link>shared ;
|
||||
lib ws2_32 : : <name>ws2_32 <link>shared ;
|
||||
|
|
|
@ -149,7 +149,7 @@ my-python-extension py_libtorrent
|
|||
<include>src
|
||||
<toolset>gcc:<cxxflags>-Wno-deprecated-declarations
|
||||
<toolset>darwin:<cxxflags>-Wno-deprecated-declarations
|
||||
<toolset>darwin:<cxxflags>-Wno-deprecated-declarations
|
||||
<toolset>darwin:<cxxflags>-Wno-unused-command-line-argument
|
||||
<conditional>@libtorrent_linking
|
||||
: # usage-requirements
|
||||
<conditional>@libtorrent_linking
|
||||
|
|
|
@ -104,9 +104,6 @@ namespace
|
|||
{ return FileIter(self, self.num_files()); }
|
||||
#endif
|
||||
|
||||
char const* filestorage_name(file_storage const& fs)
|
||||
{ return fs.name().c_str(); }
|
||||
|
||||
bool call_python_object2(boost::python::object& obj, std::string const& i)
|
||||
{
|
||||
return obj(i);
|
||||
|
|
|
@ -30,11 +30,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
*/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <libtorrent/error_code.hpp>
|
||||
#include <libtorrent/bdecode.hpp>
|
||||
#include <libtorrent/upnp.hpp>
|
||||
#include <libtorrent/socks5_stream.hpp>
|
||||
#include <boost/python.hpp>
|
||||
|
||||
using namespace boost::python;
|
||||
using namespace libtorrent;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <libtorrent/session.hpp>
|
||||
|
@ -25,6 +24,8 @@
|
|||
#include "gil.hpp"
|
||||
#include "bytes.hpp"
|
||||
|
||||
#include <boost/python.hpp>
|
||||
|
||||
using namespace boost::python;
|
||||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
@ -738,8 +739,8 @@ void bind_session()
|
|||
.def("is_paused", allow_threads(<::session::is_paused))
|
||||
.def("id", allow_threads(<::session::id))
|
||||
.def("get_cache_info", &get_cache_info1, (arg("handle") = torrent_handle(), arg("flags") = 0))
|
||||
.def("add_port_mapping", allow_threads(&session::add_port_mapping))
|
||||
.def("delete_port_mapping", allow_threads(&session::delete_port_mapping))
|
||||
.def("add_port_mapping", allow_threads(<::session::add_port_mapping))
|
||||
.def("delete_port_mapping", allow_threads(<::session::delete_port_mapping))
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
.def(
|
||||
|
@ -792,9 +793,9 @@ void bind_session()
|
|||
#endif // TORRENT_NO_DEPRECATE
|
||||
;
|
||||
|
||||
enum_<session::protocol_type>("protocol_type")
|
||||
.value("udp", session::udp)
|
||||
.value("tcp", session::tcp)
|
||||
enum_<lt::session::protocol_type>("protocol_type")
|
||||
.value("udp", lt::session::udp)
|
||||
.value("tcp", lt::session::tcp)
|
||||
;
|
||||
|
||||
enum_<lt::session::save_state_flags_t>("save_state_flags_t")
|
||||
|
|
|
@ -84,18 +84,6 @@ namespace
|
|||
ti.set_merkle_tree(h);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
file_storage::iterator begin_files(torrent_info& i)
|
||||
{
|
||||
return i.begin_files();
|
||||
}
|
||||
|
||||
file_storage::iterator end_files(torrent_info& i)
|
||||
{
|
||||
return i.end_files();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string hash_for_piece(torrent_info const& ti, int i)
|
||||
{
|
||||
return ti.hash_for_piece(i).to_string();
|
||||
|
|
|
@ -12,6 +12,7 @@ if $(BOOST_ROOT)
|
|||
project client_test
|
||||
: requirements
|
||||
<threading>multi <library>/torrent//torrent
|
||||
<toolset>darwin:<cflags>-Wno-unused-command-line-argument
|
||||
: default-build
|
||||
<link>static
|
||||
;
|
||||
|
|
|
@ -78,6 +78,7 @@ nobase_include_HEADERS = \
|
|||
max.hpp \
|
||||
natpmp.hpp \
|
||||
network_thread_pool.hpp \
|
||||
openssl.hpp \
|
||||
operations.hpp \
|
||||
packet_buffer.hpp \
|
||||
parse_url.hpp \
|
||||
|
|
|
@ -213,7 +213,7 @@ namespace libtorrent {
|
|||
// hidden
|
||||
virtual ~alert();
|
||||
#if __cplusplus >= 201103L
|
||||
alert(alert const& st) = default;
|
||||
alert(alert const&) = default;
|
||||
#endif
|
||||
|
||||
// a timestamp is automatically created in the constructor
|
||||
|
|
|
@ -57,17 +57,8 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0);
|
|||
#define TORRENT_WHILE_0 while (0)
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
||||
#ifdef TORRENT_PRODUCTION_ASSERTS
|
||||
extern char const* libtorrent_assert_log;
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_USE_SYSTEM_ASSERTS
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <sstream>
|
||||
#endif
|
||||
// declarations of the two functions
|
||||
|
||||
TORRENT_EXPORT void assert_print(char const* fmt, ...) TORRENT_FORMAT(1,2);
|
||||
|
||||
|
@ -78,6 +69,20 @@ TORRENT_NO_RETURN
|
|||
TORRENT_EXPORT void assert_fail(const char* expr, int line
|
||||
, char const* file, char const* function, char const* val, int kind = 0);
|
||||
|
||||
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
||||
#ifdef TORRENT_PRODUCTION_ASSERTS
|
||||
extern char const* libtorrent_assert_log;
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_USE_SYSTEM_ASSERTS
|
||||
|
||||
#define TORRENT_ASSERT_PRECOND(x) \
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 1); } TORRENT_WHILE_0
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#if !BOOST_PP_IS_ITERATING
|
||||
#if !defined BOOST_PP_IS_ITERATING || !BOOST_PP_IS_ITERATING
|
||||
// set-up iteration
|
||||
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
|
|
|
@ -173,8 +173,8 @@ namespace libtorrent
|
|||
cached_piece_entry();
|
||||
~cached_piece_entry();
|
||||
#if __cplusplus >= 201103L
|
||||
cached_piece_entry(cached_piece_entry const& st) = default;
|
||||
cached_piece_entry& operator=(cached_piece_entry const& st) = default;
|
||||
cached_piece_entry(cached_piece_entry const&) = default;
|
||||
cached_piece_entry& operator=(cached_piece_entry const&) = default;
|
||||
#endif
|
||||
|
||||
bool ok_to_evict(bool ignore_hash = false) const
|
||||
|
|
|
@ -439,7 +439,7 @@ int snprintf(char* buf, int len, char const* fmt, ...)
|
|||
#endif
|
||||
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
#define TORRENT_FORMAT(fmt, ellipsis) __attribute__((format(printf, fmt, ellipsis)))
|
||||
#define TORRENT_FORMAT(fmt, ellipsis) __attribute__((__format__(__printf__, fmt, ellipsis)))
|
||||
#else
|
||||
#define TORRENT_FORMAT(fmt, ellipsis)
|
||||
#endif
|
||||
|
|
|
@ -512,8 +512,8 @@ namespace libtorrent
|
|||
virtual const char* what() const TORRENT_EXCEPTION_THROW_SPECIFIER;
|
||||
virtual ~libtorrent_exception() TORRENT_EXCEPTION_THROW_SPECIFIER;
|
||||
#if __cplusplus >= 201103L
|
||||
libtorrent_exception(libtorrent_exception const& st) = default;
|
||||
libtorrent_exception& operator=(libtorrent_exception const& st) = default;
|
||||
libtorrent_exception(libtorrent_exception const&) = default;
|
||||
libtorrent_exception& operator=(libtorrent_exception const&) = default;
|
||||
#endif
|
||||
error_code error() const { return m_error; }
|
||||
private:
|
||||
|
|
|
@ -61,8 +61,8 @@ namespace libtorrent
|
|||
// hidden
|
||||
~file_entry();
|
||||
#if __cplusplus >= 201103L
|
||||
file_entry(file_entry const& st) = default;
|
||||
file_entry& operator=(file_entry const& st) = default;
|
||||
file_entry(file_entry const&) = default;
|
||||
file_entry& operator=(file_entry const&) = default;
|
||||
#endif
|
||||
|
||||
// the full path of this file. The paths are unicode strings
|
||||
|
|
|
@ -73,7 +73,7 @@ struct observer : boost::noncopyable
|
|||
, flags(0)
|
||||
{
|
||||
TORRENT_ASSERT(a);
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
m_in_constructor = true;
|
||||
m_was_sent = false;
|
||||
m_was_abandoned = false;
|
||||
|
@ -164,7 +164,7 @@ private:
|
|||
public:
|
||||
unsigned char flags;
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
bool m_in_constructor:1;
|
||||
bool m_was_sent:1;
|
||||
bool m_was_abandoned:1;
|
||||
|
|
|
@ -47,8 +47,8 @@ namespace libtorrent
|
|||
{
|
||||
socket_job() : type(none), vec(NULL), recv_buf(NULL), buf_size(0) {}
|
||||
#if __cplusplus >= 201103L
|
||||
socket_job(socket_job const& st) = default;
|
||||
socket_job& operator=(socket_job const& st) = default;
|
||||
socket_job(socket_job const&) = default;
|
||||
socket_job& operator=(socket_job const&) = default;
|
||||
#endif
|
||||
|
||||
enum job_type_t
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
|
||||
Copyright (c) 2015, Arvid Norberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TORRENT_OPENSSL_HPP_INCLUDED
|
||||
#define TORRENT_OPENSSL_HPP_INCLUDED
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
|
||||
// all of OpenSSL causes warnings, so we just have to disable them
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/safestack.h> // for sk_GENERAL_NAME_value
|
||||
#include <openssl/x509v3.h> // for GENERAL_NAME
|
||||
|
||||
inline void openssl_set_tlsext_hostname(SSL* s, char const* name)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x90812f
|
||||
SSL_set_tlsext_host_name(s, name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BOOST_VERSION >= 104700
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x90812f
|
||||
|
||||
inline void openssl_set_tlsext_servername_callback(SSL_CTX* ctx
|
||||
, int (*servername_callback)(SSL*, int*, void*))
|
||||
{
|
||||
SSL_CTX_set_tlsext_servername_callback(ctx, servername_callback);
|
||||
}
|
||||
|
||||
inline void openssl_set_tlsext_servername_arg(SSL_CTX* ctx, void* userdata)
|
||||
{
|
||||
SSL_CTX_set_tlsext_servername_arg(ctx, userdata);
|
||||
}
|
||||
|
||||
inline int openssl_num_general_names(GENERAL_NAMES* gens)
|
||||
{
|
||||
return sk_GENERAL_NAME_num(gens);
|
||||
}
|
||||
|
||||
inline GENERAL_NAME* openssl_general_name_value(GENERAL_NAMES* gens, int i)
|
||||
{
|
||||
return sk_GENERAL_NAME_value(gens, i);
|
||||
}
|
||||
|
||||
#endif // OPENSSL_VERSION_NUMBER
|
||||
#endif // BOOST_VERSION
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#endif // TORRENT_USE_OPENSSL
|
||||
|
||||
#endif // TORRENT_OPENSSL_HPP_INCLUDED
|
||||
|
|
@ -553,7 +553,9 @@ namespace libtorrent
|
|||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
void peer_log(peer_log_alert::direction_t direction
|
||||
, char const* event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5);
|
||||
, char const* event, char const* fmt, ...) const TORRENT_FORMAT(4,5);
|
||||
void peer_log(peer_log_alert::direction_t direction
|
||||
, char const* event) const;
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
|
|
|
@ -52,8 +52,8 @@ namespace libtorrent
|
|||
{
|
||||
feed_item();
|
||||
#if __cplusplus >= 201103L
|
||||
feed_item(feed_item const& st) = default;
|
||||
feed_item & operator=(feed_item const& st) = default;
|
||||
feed_item(feed_item const&) = default;
|
||||
feed_item & operator=(feed_item const&) = default;
|
||||
#endif
|
||||
~feed_item();
|
||||
|
||||
|
|
|
@ -126,8 +126,8 @@ namespace libtorrent
|
|||
session_proxy() {}
|
||||
~session_proxy();
|
||||
#if __cplusplus >= 201103L
|
||||
session_proxy(session_proxy const& st) = default;
|
||||
session_proxy& operator=(session_proxy const& st) = default;
|
||||
session_proxy(session_proxy const&) = default;
|
||||
session_proxy& operator=(session_proxy const&) = default;
|
||||
#endif
|
||||
private:
|
||||
session_proxy(
|
||||
|
|
|
@ -60,8 +60,8 @@ namespace libtorrent
|
|||
LIBTORRENT_VERSION);
|
||||
~session_settings();
|
||||
#if __cplusplus >= 201103L
|
||||
session_settings(session_settings const& st) = default;
|
||||
session_settings& operator=(session_settings const& st) = default;
|
||||
session_settings(session_settings const&) = default;
|
||||
session_settings& operator=(session_settings const&) = default;
|
||||
#endif
|
||||
|
||||
// automatically set to the libtorrent version you're using in order to
|
||||
|
|
|
@ -43,6 +43,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/max.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
#include "libtorrent/ssl_stream.hpp"
|
||||
#endif
|
||||
|
@ -282,13 +288,13 @@ namespace libtorrent
|
|||
template <class S> S* get()
|
||||
{
|
||||
if (m_type != socket_type_int_impl<S>::value) return 0;
|
||||
return reinterpret_cast<S*>(m_data);
|
||||
return reinterpret_cast<S*>(&m_data);
|
||||
}
|
||||
|
||||
template <class S> S const* get() const
|
||||
{
|
||||
if (m_type != socket_type_int_impl<S>::value) return 0;
|
||||
return reinterpret_cast<S const*>(m_data);
|
||||
return reinterpret_cast<S const*>(&m_data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -321,10 +327,7 @@ namespace libtorrent
|
|||
>::value
|
||||
};
|
||||
|
||||
// TODO: 2 it would be nice to use aligned_storage here when
|
||||
// building on c++11
|
||||
boost::int64_t m_data[(storage_size + sizeof(boost::int64_t) - 1)
|
||||
/ sizeof(boost::int64_t)];
|
||||
boost::aligned_storage<storage_size, 16>::type m_data;
|
||||
};
|
||||
|
||||
// returns true if this socket is an SSL socket
|
||||
|
|
|
@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/io_service.hpp"
|
||||
#include "libtorrent/openssl.hpp"
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
||||
|
@ -87,9 +88,7 @@ public:
|
|||
|
||||
void set_host_name(std::string name)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x90812f
|
||||
SSL_set_tlsext_host_name(m_sock.native_handle(), name.c_str());
|
||||
#endif
|
||||
openssl_set_tlsext_hostname(m_sock.native_handle(), name.c_str());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -253,7 +253,7 @@ namespace libtorrent
|
|||
{ if (!t.m_torrent.expired()) m_torrent = t.m_torrent; }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
torrent_handle& operator=(torrent_handle const& st) = default;
|
||||
torrent_handle& operator=(torrent_handle const&) = default;
|
||||
#endif
|
||||
|
||||
// flags for add_piece().
|
||||
|
@ -1261,8 +1261,8 @@ namespace libtorrent
|
|||
torrent_status();
|
||||
~torrent_status();
|
||||
#if __cplusplus >= 201103L
|
||||
torrent_status(torrent_status const& st) = default;
|
||||
torrent_status& operator=(torrent_status const& st) = default;
|
||||
torrent_status(torrent_status const&) = default;
|
||||
torrent_status& operator=(torrent_status const&) = default;
|
||||
#endif
|
||||
|
||||
// compres if the torrent status objects come from the same torrent. i.e.
|
||||
|
|
|
@ -84,8 +84,8 @@ namespace libtorrent
|
|||
announce_entry();
|
||||
~announce_entry();
|
||||
#if __cplusplus >= 201103L
|
||||
announce_entry(announce_entry const& st) = default;
|
||||
announce_entry& operator=(announce_entry const& st) = default;
|
||||
announce_entry(announce_entry const&) = default;
|
||||
announce_entry& operator=(announce_entry const&) = default;
|
||||
#endif
|
||||
|
||||
// tracker URL as it appeared in the torrent file
|
||||
|
|
|
@ -295,8 +295,8 @@ private:
|
|||
magic = 0;
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
rootdevice(rootdevice const& st) = default;
|
||||
rootdevice& operator=(rootdevice const& st) = default;
|
||||
rootdevice(rootdevice const&) = default;
|
||||
rootdevice& operator=(rootdevice const&) = default;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -881,9 +881,10 @@ namespace libtorrent {
|
|||
|
||||
std::string listen_succeeded_alert::message() const
|
||||
{
|
||||
char const* type_str[] = { "TCP", "SSL/TCP", "UDP", "SSL/uTP" };
|
||||
char ret[200];
|
||||
snprintf(ret, sizeof(ret), "successfully listening on [%s] %s"
|
||||
, sock_type_str[sock_type], print_endpoint(endpoint).c_str());
|
||||
, type_str[sock_type], print_endpoint(endpoint).c_str());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,27 +112,26 @@ namespace libtorrent
|
|||
bytes = num_pages * page;
|
||||
#endif
|
||||
|
||||
char* ret;
|
||||
void* ret;
|
||||
#if TORRENT_USE_POSIX_MEMALIGN
|
||||
if (posix_memalign(reinterpret_cast<void**>(&ret), page_size(), bytes)
|
||||
if (posix_memalign(&ret, page_size(), bytes)
|
||||
!= 0) ret = NULL;
|
||||
#elif TORRENT_USE_MEMALIGN
|
||||
ret = static_cast<char*>(memalign(page_size(), bytes));
|
||||
ret = memalign(page_size(), bytes);
|
||||
#elif defined TORRENT_WINDOWS
|
||||
ret = static_cast<char*>(_aligned_malloc(bytes, page_size()));
|
||||
ret = _aligned_malloc(bytes, page_size());
|
||||
#elif defined TORRENT_BEOS
|
||||
area_id id = create_area("", &ret, B_ANY_ADDRESS
|
||||
, (bytes + page_size() - 1) & (page_size()-1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||
if (id < B_OK) return NULL;
|
||||
ret = static_cast<char*>(ret);
|
||||
#else
|
||||
ret = static_cast<char*>(valloc(size_t(bytes)));
|
||||
ret = valloc(size_t(bytes));
|
||||
#endif
|
||||
if (ret == NULL) return NULL;
|
||||
|
||||
#ifdef TORRENT_DEBUG_BUFFERS
|
||||
// make the two surrounding pages non-readable and -writable
|
||||
alloc_header* h = (alloc_header*)ret;
|
||||
alloc_header* h = static_cast<alloc_header*>(ret);
|
||||
h->size = orig_bytes;
|
||||
h->magic = 0x1337;
|
||||
print_backtrace(h->stack, sizeof(h->stack));
|
||||
|
@ -142,7 +141,7 @@ namespace libtorrent
|
|||
#define PROT_READ PAGE_READONLY
|
||||
#endif
|
||||
mprotect(ret, page, PROT_READ);
|
||||
mprotect(ret + (num_pages-1) * page, page, PROT_READ);
|
||||
mprotect(static_cast<char*>(ret) + (num_pages-1) * page, page, PROT_READ);
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#undef mprotect
|
||||
|
@ -150,10 +149,10 @@ namespace libtorrent
|
|||
#endif
|
||||
// fprintf(stderr, "malloc: %p head: %p tail: %p size: %d\n", ret + page, ret, ret + page + bytes, int(bytes));
|
||||
|
||||
return ret + page;
|
||||
return static_cast<char*>(ret) + page;
|
||||
#else
|
||||
return static_cast<char*>(ret);
|
||||
#endif // TORRENT_DEBUG_BUFFERS
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void page_aligned_allocator::free(char* block)
|
||||
|
@ -170,7 +169,7 @@ namespace libtorrent
|
|||
const int page = page_size();
|
||||
// make the two surrounding pages non-readable and -writable
|
||||
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
||||
alloc_header* h = (alloc_header*)(block - page);
|
||||
alloc_header* h = reinterpret_cast<alloc_header*>(block - page);
|
||||
const int num_pages = (h->size + (page-1)) / page + 2;
|
||||
TORRENT_ASSERT(h->magic == 0x1337);
|
||||
mprotect(block + (num_pages-2) * page, page, PROT_READ | PROT_WRITE);
|
||||
|
@ -203,7 +202,7 @@ namespace libtorrent
|
|||
bool page_aligned_allocator::in_use(char const* block)
|
||||
{
|
||||
const int page = page_size();
|
||||
alloc_header* h = (alloc_header*)(block - page);
|
||||
alloc_header const* h = reinterpret_cast<alloc_header const*>(block - page);
|
||||
return h->magic == 0x1337;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -301,8 +301,11 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line
|
|||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
#elif !TORRENT_USE_ASSERTS
|
||||
|
||||
// these are just here to make it possible for a client that built with debug
|
||||
// enable to be able to link against a release build (just possible, not
|
||||
// necessarily supported)
|
||||
TORRENT_FORMAT(1,2)
|
||||
TORRENT_EXPORT void assert_print(char const*, ...) {}
|
||||
TORRENT_EXPORT void assert_fail(char const*, int, char const*
|
||||
|
|
|
@ -49,12 +49,20 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/random.hpp"
|
||||
#endif
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
||||
#if TORRENT_USE_PURGABLE_CONTROL
|
||||
#include <mach/mach.h>
|
||||
// see comments at:
|
||||
// http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/vm_object.c
|
||||
|
||||
const vm_purgable_t vm_purgable_set_state = VM_PURGABLE_SET_STATE;
|
||||
const vm_purgable_t vm_purgable_nonvolatile = VM_PURGABLE_NONVOLATILE;
|
||||
|
||||
#endif
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
/*
|
||||
|
||||
The disk cache mimics ARC (adaptive replacement cache).
|
||||
|
@ -161,7 +169,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#define DEBUG_CACHE 0
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#if __cplusplus >= 201103L || defined __clang__
|
||||
|
||||
#if DEBUG_CACHE
|
||||
#define DLOG(...) fprintf(__VA_ARGS__)
|
||||
|
@ -292,7 +300,8 @@ const char* const job_action_name[] =
|
|||
, int(pe->read_jobs.size()), int(pe->jobs.size()));
|
||||
for (int i = 0; i < pe->piece_log.size(); ++i)
|
||||
{
|
||||
assert_print(&", %s (%d)"[i==0], job_name(pe->piece_log[i].job), pe->piece_log[i].block);
|
||||
assert_print("%s %s (%d)", (i==0?"":",")
|
||||
, job_name(pe->piece_log[i].job), pe->piece_log[i].block);
|
||||
}
|
||||
}
|
||||
assert_print("\n");
|
||||
|
@ -880,7 +889,7 @@ void block_cache::mark_for_deletion(cached_piece_entry* p)
|
|||
INVARIANT_CHECK;
|
||||
|
||||
DLOG(stderr, "[%p] block_cache mark-for-deletion "
|
||||
"piece: %d\n", this, int(p->piece));
|
||||
"piece: %d\n", static_cast<void*>(this), int(p->piece));
|
||||
|
||||
TORRENT_PIECE_ASSERT(p->jobs.empty(), p);
|
||||
tailqueue<disk_io_job> jobs;
|
||||
|
@ -919,7 +928,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
|
||||
if (num <= 0) return 0;
|
||||
|
||||
DLOG(stderr, "[%p] try_evict_blocks: %d\n", this, num);
|
||||
DLOG(stderr, "[%p] try_evict_blocks: %d\n", static_cast<void*>(this), num);
|
||||
|
||||
char** to_delete = TORRENT_ALLOCA(char*, num);
|
||||
int num_to_delete = 0;
|
||||
|
@ -1107,7 +1116,8 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
|
||||
if (num_to_delete == 0) return num;
|
||||
|
||||
DLOG(stderr, "[%p] removed %d blocks\n", this, num_to_delete);
|
||||
DLOG(stderr, "[%p] removed %d blocks\n", static_cast<void*>(this)
|
||||
, num_to_delete);
|
||||
|
||||
free_multiple_buffers(to_delete, num_to_delete);
|
||||
|
||||
|
@ -1270,14 +1280,15 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
|
|||
kern_return_t ret = vm_purgable_control(
|
||||
mach_task_self(),
|
||||
reinterpret_cast<vm_address_t>(pe->blocks[block].buf),
|
||||
VM_PURGABLE_SET_STATE,
|
||||
vm_purgable_set_state,
|
||||
&state);
|
||||
#ifdef TORRENT_DEBUG
|
||||
// if ((random() % 200) == 0) ret = 1;
|
||||
#endif
|
||||
if (ret != KERN_SUCCESS || (state & VM_PURGABLE_EMPTY))
|
||||
{
|
||||
fprintf(stderr, "insert_blocks(piece=%d block=%d): vm_purgable_control failed: %d state & VM_PURGABLE_EMPTY: %d\n"
|
||||
fprintf(stderr, "insert_blocks(piece=%d block=%d): "
|
||||
"vm_purgable_control failed: %d state & VM_PURGABLE_EMPTY: %d\n"
|
||||
, pe->piece, block, ret, state & VM_PURGABLE_EMPTY);
|
||||
free_buffer(pe->blocks[block].buf);
|
||||
pe->blocks[block].buf = NULL;
|
||||
|
@ -1315,18 +1326,19 @@ bool block_cache::inc_block_refcount(cached_piece_entry* pe, int block, int reas
|
|||
// its still here. It's only volatile if it's not dirty and has refcount == 0
|
||||
if (!pe->blocks[block].dirty)
|
||||
{
|
||||
int state = VM_PURGABLE_NONVOLATILE;
|
||||
int state = vm_purgable_nonvolatile;
|
||||
kern_return_t ret = vm_purgable_control(
|
||||
mach_task_self(),
|
||||
reinterpret_cast<vm_address_t>(pe->blocks[block].buf),
|
||||
VM_PURGABLE_SET_STATE,
|
||||
vm_purgable_set_state,
|
||||
&state);
|
||||
#ifdef TORRENT_DEBUG
|
||||
// if ((random() % 200) == 0) ret = 1;
|
||||
#endif
|
||||
if (ret != KERN_SUCCESS || (state & VM_PURGABLE_EMPTY))
|
||||
{
|
||||
fprintf(stderr, "inc_block_refcount(piece=%d block=%d): vm_purgable_control failed: %d state & VM_PURGABLE_EMPTY: %d\n"
|
||||
fprintf(stderr, "inc_block_refcount(piece=%d block=%d): "
|
||||
"vm_purgable_control failed: %d state & VM_PURGABLE_EMPTY: %d\n"
|
||||
, pe->piece, block, ret, state & VM_PURGABLE_EMPTY);
|
||||
|
||||
free_buffer(pe->blocks[block].buf);
|
||||
|
@ -1385,14 +1397,15 @@ void block_cache::dec_block_refcount(cached_piece_entry* pe, int block, int reas
|
|||
kern_return_t ret = vm_purgable_control(
|
||||
mach_task_self(),
|
||||
reinterpret_cast<vm_address_t>(pe->blocks[block].buf),
|
||||
VM_PURGABLE_SET_STATE,
|
||||
vm_purgable_set_state,
|
||||
&state);
|
||||
#ifdef TORRENT_DEBUG
|
||||
// if ((random() % 200) == 0) ret = 1;
|
||||
#endif
|
||||
if (ret != KERN_SUCCESS || (state & VM_PURGABLE_EMPTY))
|
||||
{
|
||||
fprintf(stderr, "dec_block_refcount(piece=%d block=%d): vm_purgable_control failed: %d state & VM_PURGABLE_EMPTY: %d\n"
|
||||
fprintf(stderr, "dec_block_refcount(piece=%d block=%d): "
|
||||
"vm_purgable_control failed: %d state & VM_PURGABLE_EMPTY: %d\n"
|
||||
, pe->piece, block, ret, state & VM_PURGABLE_EMPTY);
|
||||
free_buffer(pe->blocks[block].buf);
|
||||
pe->blocks[block].buf = NULL;
|
||||
|
@ -1827,7 +1840,8 @@ bool block_cache::maybe_free_piece(cached_piece_entry* pe)
|
|||
boost::shared_ptr<piece_manager> s = pe->storage;
|
||||
|
||||
DLOG(stderr, "[%p] block_cache maybe_free_piece "
|
||||
"piece: %d refcount: %d marked_for_deletion: %d\n", this
|
||||
"piece: %d refcount: %d marked_for_deletion: %d\n"
|
||||
, static_cast<void*>(this)
|
||||
, int(pe->piece), int(pe->refcount), int(pe->marked_for_deletion));
|
||||
|
||||
tailqueue<disk_io_job> jobs;
|
||||
|
|
|
@ -401,11 +401,6 @@ namespace libtorrent
|
|||
stats_counters().inc_stats_counter(counters::num_outgoing_suggest);
|
||||
}
|
||||
|
||||
namespace {
|
||||
char random_byte()
|
||||
{ return random() & 0xff; }
|
||||
}
|
||||
|
||||
void bt_peer_connection::get_specific_peer_info(peer_info& p) const
|
||||
{
|
||||
TORRENT_ASSERT(!associated_torrent().expired());
|
||||
|
@ -446,6 +441,11 @@ namespace libtorrent
|
|||
|
||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||
|
||||
namespace {
|
||||
char random_byte()
|
||||
{ return random() & 0xff; }
|
||||
}
|
||||
|
||||
void bt_peer_connection::write_pe1_2_dhkey()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
@ -728,7 +728,6 @@ namespace libtorrent
|
|||
int packet_size = 0;
|
||||
m_rc4->decrypt(vec, consume, produce, packet_size);
|
||||
}
|
||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||
|
||||
namespace {
|
||||
void regular_c_free(char* buf, void* /* userdata */
|
||||
|
@ -738,6 +737,8 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||
|
||||
void bt_peer_connection::append_const_send_buffer(char const* buffer, int size
|
||||
, chained_buffer::free_buffer_fun destructor, void* userdata
|
||||
, block_cache_reference ref)
|
||||
|
|
|
@ -56,12 +56,23 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
|
||||
#if TORRENT_USE_RLIMIT
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#endif // __GNUC__
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
// capture this here where warnings are disabled (the macro generates warnings)
|
||||
const rlim_t rlimit_as = RLIMIT_AS;
|
||||
const rlim_t rlim_infinity = RLIM_INFINITY;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__
|
||||
|
||||
#endif // TORRENT_USE_RLIMIT
|
||||
|
||||
#ifdef TORRENT_LINUX
|
||||
#include <linux/unistd.h>
|
||||
|
|
|
@ -61,7 +61,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#define DEBUG_DISK_THREAD 0
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#if __cplusplus >= 201103L || defined __clang__
|
||||
|
||||
#if DEBUG_DISK_THREAD
|
||||
#define DLOG(...) debug_log(__VA_ARGS__)
|
||||
|
@ -93,6 +93,11 @@ namespace libtorrent
|
|||
|
||||
namespace {
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
void debug_log(char const* fmt, ...)
|
||||
{
|
||||
#if DEBUG_DISK_THREAD
|
||||
|
@ -133,6 +138,10 @@ namespace libtorrent
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// ------- disk_io_thread ------
|
||||
|
|
|
@ -232,7 +232,7 @@ namespace libtorrent { namespace
|
|||
}
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_SYSCTL
|
||||
#if TORRENT_USE_SYSCTL && !defined TORRENT_BUILD_SIMULATOR
|
||||
#ifdef TORRENT_OS2
|
||||
int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
|
||||
#endif
|
||||
|
@ -285,7 +285,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||
}
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_IFADDRS
|
||||
#if TORRENT_USE_IFADDRS && !defined TORRENT_BUILD_SIMULATOR
|
||||
bool iface_from_ifaddrs(ifaddrs *ifa, ip_interface &rv)
|
||||
{
|
||||
int family = ifa->ifa_addr->sa_family;
|
||||
|
|
15
src/file.cpp
15
src/file.cpp
|
@ -1300,15 +1300,18 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifdef TORRENT_DISK_STATS
|
||||
boost::uint32_t silly_hash(std::string const& str)
|
||||
namespace
|
||||
{
|
||||
boost::uint32_t ret = 1;
|
||||
for (int i = 0; i < str.size(); ++i)
|
||||
boost::uint32_t silly_hash(std::string const& str)
|
||||
{
|
||||
if (str[i] == 0) continue;
|
||||
ret *= int(str[i]);
|
||||
boost::uint32_t ret = 1;
|
||||
for (int i = 0; i < str.size(); ++i)
|
||||
{
|
||||
if (str[i] == 0) continue;
|
||||
ret *= int(str[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -339,9 +339,13 @@ void http_connection::start(std::string const& hostname, int port
|
|||
if (m_ssl_ctx)
|
||||
{
|
||||
m_own_ssl_context = true;
|
||||
error_code ec;
|
||||
m_ssl_ctx->set_verify_mode(ssl::context::verify_none, ec);
|
||||
TORRENT_ASSERT(!ec);
|
||||
if (ec)
|
||||
{
|
||||
m_timer.get_io_service().post(boost::bind(&http_connection::callback
|
||||
, me, ec, static_cast<char*>(NULL), 0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
userdata = m_ssl_ctx;
|
||||
|
|
|
@ -126,7 +126,7 @@ observer_ptr find_data::new_observer(void* ptr
|
|||
, udp::endpoint const& ep, node_id const& id)
|
||||
{
|
||||
observer_ptr o(new (ptr) find_data_observer(this, ep, id));
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
return o;
|
||||
|
|
|
@ -336,7 +336,7 @@ namespace
|
|||
void* ptr = node.m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
observer_ptr o(new (ptr) announce_observer(algo, i->first.ep(), i->first.id));
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
entry e;
|
||||
|
@ -422,7 +422,7 @@ void node::direct_request(boost::asio::ip::udp::endpoint ep, entry& e
|
|||
void* ptr = m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
observer_ptr o(new (ptr) direct_observer(algo, ep, (node_id::min)()));
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
m_rpc.invoke(e, ep, o);
|
||||
|
@ -561,7 +561,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int bucket
|
|||
boost::intrusive_ptr<traversal_algorithm> algo(
|
||||
new traversal_algorithm(*this, (node_id::min)()));
|
||||
observer_ptr o(new (ptr) ping_observer(algo, ep, id));
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
entry e;
|
||||
|
|
|
@ -45,7 +45,7 @@ observer_ptr bootstrap::new_observer(void* ptr
|
|||
, udp::endpoint const& ep, node_id const& id)
|
||||
{
|
||||
observer_ptr o(new (ptr) get_peers_observer(this, ep, id));
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
#endif
|
||||
return o;
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace libtorrent { namespace
|
|||
|
||||
virtual boost::shared_ptr<peer_plugin> new_connection(
|
||||
peer_connection_handle const& pc);
|
||||
|
||||
|
||||
virtual void tick()
|
||||
{
|
||||
if (m_2_minutes++ < 120) return;
|
||||
|
|
|
@ -107,9 +107,10 @@ namespace libtorrent { namespace
|
|||
m_requested_metadata.resize(256, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
bool need_loaded()
|
||||
{ return m_torrent.need_loaded(); }
|
||||
|
||||
*/
|
||||
virtual void on_unload()
|
||||
{
|
||||
m_metadata.reset();
|
||||
|
@ -225,7 +226,9 @@ namespace libtorrent { namespace
|
|||
metadata();
|
||||
}
|
||||
|
||||
/*
|
||||
int metadata_size() const { return m_metadata_size; }
|
||||
*/
|
||||
|
||||
private:
|
||||
torrent& m_torrent;
|
||||
|
|
|
@ -3678,9 +3678,9 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
|
|||
|
||||
#ifdef BN_MP_INVMOD_SLOW_C
|
||||
return mp_invmod_slow(a, b, c);
|
||||
#endif
|
||||
|
||||
#else
|
||||
return MP_VAL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -35,10 +35,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/cstdint.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "libtorrent/tommath.h"
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include "libtorrent/random.hpp"
|
||||
#include "libtorrent/pe_crypto.hpp"
|
||||
#include "libtorrent/hasher.hpp"
|
||||
|
@ -175,7 +184,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(to_process == 0);
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
to_process = 0;
|
||||
for (std::vector<boost::asio::mutable_buffer>::iterator i = iovec.begin();
|
||||
i != iovec.end(); ++i)
|
||||
|
@ -193,7 +202,7 @@ namespace libtorrent
|
|||
m_send_barriers.pop_front();
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
if (next_barrier != INT_MAX)
|
||||
{
|
||||
int overhead = 0;
|
||||
|
|
|
@ -502,6 +502,12 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
void peer_connection::peer_log(peer_log_alert::direction_t direction
|
||||
, char const* event) const
|
||||
{
|
||||
peer_log(direction, event, "");
|
||||
}
|
||||
|
||||
TORRENT_FORMAT(4,5)
|
||||
void peer_connection::peer_log(peer_log_alert::direction_t direction
|
||||
, char const* event, char const* fmt, ...) const
|
||||
|
|
|
@ -229,7 +229,14 @@ void peer_connection_handle::peer_log(peer_log_alert::direction_t direction
|
|||
TORRENT_ASSERT(pc);
|
||||
va_list v;
|
||||
va_start(v, fmt);
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
pc->peer_log(direction, event, fmt, v);
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
va_end(v);
|
||||
#else
|
||||
TORRENT_UNUSED(direction);
|
||||
|
|
|
@ -38,12 +38,23 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/cstdint.hpp>
|
||||
|
||||
#if TORRENT_USE_RLIMIT
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#endif // __GNUC__
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
// capture this here where warnings are disabled (the macro generates warnings)
|
||||
const rlim_t rlimit_as = RLIMIT_AS;
|
||||
const rlim_t rlim_infinity = RLIM_INFINITY;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__
|
||||
|
||||
#endif // TORRENT_USE_RLIMIT
|
||||
|
||||
#ifdef TORRENT_BSD
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -221,7 +221,7 @@ void receive_buffer::mutable_buffers(std::vector<boost::asio::mutable_buffer>& v
|
|||
, m_recv_pos - regular_buf_size));
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS
|
||||
int vec_bytes = 0;
|
||||
for (std::vector<asio::mutable_buffer>::iterator i = vec.begin();
|
||||
i != vec.end(); ++i)
|
||||
|
|
|
@ -503,7 +503,7 @@ namespace libtorrent
|
|||
bencode(std::back_inserter(buf), ses_state);
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
int ret =
|
||||
#endif
|
||||
bdecode(&buf[0], &buf[0] + buf.size(), e, ec);
|
||||
|
@ -528,7 +528,7 @@ namespace libtorrent
|
|||
std::pair<char const*, int> buf = ses_state.data_section();
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
|
||||
int ret =
|
||||
#endif
|
||||
bdecode(buf.first, buf.first + buf.second, e, ec);
|
||||
|
|
|
@ -52,21 +52,31 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/function_equal.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#ifndef TORRENT_WINDOWS
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_USE_VALGRIND
|
||||
#include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_RLIMIT
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#endif // __GNUC__
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
// capture this here where warnings are disabled (the macro generates warnings)
|
||||
const rlim_t rlim_infinity = RLIM_INFINITY;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__
|
||||
|
||||
#endif // TORRENT_USE_RLIMIT
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#include "libtorrent/openssl.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
#include "libtorrent/tracker_manager.hpp"
|
||||
|
@ -289,22 +299,23 @@ namespace aux {
|
|||
}
|
||||
|
||||
#if defined TORRENT_USE_OPENSSL && BOOST_VERSION >= 104700 && OPENSSL_VERSION_NUMBER >= 0x90812f
|
||||
namespace {
|
||||
// when running bittorrent over SSL, the SNI (server name indication)
|
||||
// extension is used to know which torrent the incoming connection is
|
||||
// trying to connect to. The 40 first bytes in the name is expected to
|
||||
// be the hex encoded info-hash
|
||||
int servername_callback(SSL *s, int *ad, void *arg)
|
||||
int servername_callback(SSL* s, int* ad, void* arg)
|
||||
{
|
||||
TORRENT_UNUSED(ad);
|
||||
|
||||
session_impl* ses = (session_impl*)arg;
|
||||
session_impl* ses = reinterpret_cast<session_impl*>(arg);
|
||||
const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
|
||||
|
||||
if (!servername || strlen(servername) < 40)
|
||||
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
|
||||
sha1_hash info_hash;
|
||||
bool valid = from_hex(servername, 40, (char*)&info_hash[0]);
|
||||
bool valid = from_hex(servername, 40, info_hash.data());
|
||||
|
||||
// the server name is not a valid hex-encoded info-hash
|
||||
if (!valid)
|
||||
|
@ -331,6 +342,7 @@ namespace aux {
|
|||
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
} // anonymous namesoace
|
||||
#endif
|
||||
|
||||
session_impl::session_impl(io_service& ios)
|
||||
|
@ -456,8 +468,9 @@ namespace aux {
|
|||
m_ssl_ctx.set_verify_mode(boost::asio::ssl::context::verify_none, ec);
|
||||
#if BOOST_VERSION >= 104700
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x90812f
|
||||
SSL_CTX_set_tlsext_servername_callback(m_ssl_ctx.native_handle(), servername_callback);
|
||||
SSL_CTX_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this);
|
||||
openssl_set_tlsext_servername_callback(m_ssl_ctx.native_handle()
|
||||
, servername_callback);
|
||||
openssl_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this);
|
||||
#endif // OPENSSL_VERSION_NUMBER
|
||||
#endif // BOOST_VERSION
|
||||
#endif
|
||||
|
@ -1926,14 +1939,14 @@ retry:
|
|||
#ifdef TORRENT_USE_OPENSSL
|
||||
if (m_settings.get_int(settings_pack::ssl_listen))
|
||||
{
|
||||
listen_socket_t s = setup_listener(device, address_family
|
||||
listen_socket_t ssl_s = setup_listener(device, address_family
|
||||
, m_settings.get_int(settings_pack::ssl_listen)
|
||||
, flags | open_ssl_socket, ec);
|
||||
|
||||
if (!ec && s.sock)
|
||||
if (!ec && ssl_s.sock)
|
||||
{
|
||||
TORRENT_ASSERT(!m_abort);
|
||||
m_listen_sockets.push_back(s);
|
||||
m_listen_sockets.push_back(ssl_s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
10
src/sha1.cpp
10
src/sha1.cpp
|
@ -31,6 +31,11 @@ namespace
|
|||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-member-function"
|
||||
#endif
|
||||
|
||||
// blk0() and blk() perform the initial expand.
|
||||
// I got the idea of expanding during the round function from SSLeay
|
||||
struct little_endian_blk0
|
||||
|
@ -50,9 +55,12 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||
|
||||
// (R0+R1), R2, R3, R4 are the different operations used in SHA1
|
||||
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+BlkFun::apply(block, i)+0x5A827999+rol(v,5);w=rol(w,30);
|
||||
|
|
|
@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/socket_type.hpp"
|
||||
#include "libtorrent/openssl.hpp"
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
#include <boost/asio/ssl/context.hpp>
|
||||
|
@ -114,8 +115,8 @@ namespace libtorrent
|
|||
#if OPENSSL_VERSION_NUMBER >= 0x90812f
|
||||
if (ctx)
|
||||
{
|
||||
SSL_CTX_set_tlsext_servername_callback(ctx, 0);
|
||||
SSL_CTX_set_tlsext_servername_arg(ctx, 0);
|
||||
openssl_set_tlsext_servername_callback(ctx, 0);
|
||||
openssl_set_tlsext_servername_arg(ctx, 0);
|
||||
}
|
||||
#endif // OPENSSL_VERSION_NUMBER
|
||||
#else
|
||||
|
@ -227,41 +228,41 @@ namespace libtorrent
|
|||
{
|
||||
case 0: break;
|
||||
case socket_type_int_impl<tcp::socket>::value:
|
||||
new (reinterpret_cast<tcp::socket*>(m_data)) tcp::socket(m_io_service);
|
||||
new (reinterpret_cast<tcp::socket*>(&m_data)) tcp::socket(m_io_service);
|
||||
break;
|
||||
case socket_type_int_impl<socks5_stream>::value:
|
||||
new (reinterpret_cast<socks5_stream*>(m_data)) socks5_stream(m_io_service);
|
||||
new (reinterpret_cast<socks5_stream*>(&m_data)) socks5_stream(m_io_service);
|
||||
break;
|
||||
case socket_type_int_impl<http_stream>::value:
|
||||
new (reinterpret_cast<http_stream*>(m_data)) http_stream(m_io_service);
|
||||
new (reinterpret_cast<http_stream*>(&m_data)) http_stream(m_io_service);
|
||||
break;
|
||||
case socket_type_int_impl<utp_stream>::value:
|
||||
new (reinterpret_cast<utp_stream*>(m_data)) utp_stream(m_io_service);
|
||||
new (reinterpret_cast<utp_stream*>(&m_data)) utp_stream(m_io_service);
|
||||
break;
|
||||
#if TORRENT_USE_I2P
|
||||
case socket_type_int_impl<i2p_stream>::value:
|
||||
new (reinterpret_cast<i2p_stream*>(m_data)) i2p_stream(m_io_service);
|
||||
new (reinterpret_cast<i2p_stream*>(&m_data)) i2p_stream(m_io_service);
|
||||
break;
|
||||
#endif
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
case socket_type_int_impl<ssl_stream<tcp::socket> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<tcp::socket>*)m_data) ssl_stream<tcp::socket>(m_io_service
|
||||
new (reinterpret_cast<ssl_stream<tcp::socket>*>(&m_data)) ssl_stream<tcp::socket>(m_io_service
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
case socket_type_int_impl<ssl_stream<socks5_stream> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<socks5_stream>*)m_data) ssl_stream<socks5_stream>(m_io_service
|
||||
new (reinterpret_cast<ssl_stream<socks5_stream>*>(&m_data)) ssl_stream<socks5_stream>(m_io_service
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
case socket_type_int_impl<ssl_stream<http_stream> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<http_stream>*)m_data) ssl_stream<http_stream>(m_io_service
|
||||
new (reinterpret_cast<ssl_stream<http_stream>*>(&m_data)) ssl_stream<http_stream>(m_io_service
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
case socket_type_int_impl<ssl_stream<utp_stream> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<utp_stream>*)m_data) ssl_stream<utp_stream>(m_io_service
|
||||
new (reinterpret_cast<ssl_stream<utp_stream>*>(&m_data)) ssl_stream<utp_stream>(m_io_service
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -90,7 +90,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define DEBUG_STORAGE 0
|
||||
#define DEBUG_DELETE_FILES 0
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#if __cplusplus >= 201103L || defined __clang__
|
||||
|
||||
#if DEBUG_STORAGE
|
||||
#define DLOG(...) fprintf(__VA_ARGS__)
|
||||
|
@ -217,7 +217,7 @@ namespace libtorrent
|
|||
char* ptr = event;
|
||||
detail::write_uint64(timestamp.time_since_epoch().count(), ptr);
|
||||
detail::write_uint64(offset, ptr);
|
||||
detail::write_uint64((boost::uint64_t)event_id++, ptr);
|
||||
detail::write_uint64(static_cast<boost::uint64_t>(event_id++), ptr);
|
||||
detail::write_uint32(fileid, ptr);
|
||||
detail::write_uint8(flags, ptr);
|
||||
|
||||
|
@ -574,7 +574,8 @@ namespace libtorrent
|
|||
{
|
||||
remove(p, ec);
|
||||
|
||||
DFLOG(stderr, "[%p] delete_one_file: %s [%s]\n", this, p.c_str(), ec.message().c_str());
|
||||
DFLOG(stderr, "[%p] delete_one_file: %s [%s]\n", static_cast<void*>(this)
|
||||
, p.c_str(), ec.message().c_str());
|
||||
|
||||
if (ec == boost::system::errc::no_such_file_or_directory)
|
||||
ec.clear();
|
||||
|
@ -582,7 +583,7 @@ namespace libtorrent
|
|||
|
||||
void default_storage::delete_files(storage_error& ec)
|
||||
{
|
||||
DFLOG(stderr, "[%p] delete_files\n", this);
|
||||
DFLOG(stderr, "[%p] delete_files\n", static_cast<void*>(this));
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
// this is a fence job, we expect no other
|
||||
|
@ -644,12 +645,13 @@ namespace libtorrent
|
|||
|
||||
error_code error;
|
||||
remove(combine_path(m_save_path, m_part_file_name), error);
|
||||
DFLOG(stderr, "[%p] delete partfile %s/%s [%s]\n", this
|
||||
DFLOG(stderr, "[%p] delete partfile %s/%s [%s]\n", static_cast<void*>(this)
|
||||
, m_save_path.c_str(), m_part_file_name.c_str(), error.message().c_str());
|
||||
if (error != boost::system::errc::no_such_file_or_directory && !error)
|
||||
{ ec.file = -1; ec.ec = error; ec.operation = storage_error::remove; }
|
||||
|
||||
DFLOG(stderr, "[%p] delete_files result: %s\n", this, ec.ec.message().c_str());
|
||||
DFLOG(stderr, "[%p] delete_files result: %s\n", static_cast<void*>(this)
|
||||
, ec.ec.message().c_str());
|
||||
|
||||
#if defined TORRENT_DEBUG_FILE_LEAKS
|
||||
print_open_files("delete-files done", m_files.name().c_str());
|
||||
|
@ -1701,7 +1703,7 @@ namespace libtorrent
|
|||
{
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
DLOG(stderr, "[%p] is_blocked: fence: %d num_outstanding: %d\n"
|
||||
, this, m_has_fence, int(m_outstanding_jobs));
|
||||
, static_cast<void*>(this), m_has_fence, int(m_outstanding_jobs));
|
||||
|
||||
// if this is the job that raised the fence, don't block it
|
||||
// ignore fence can only ignore one fence. If there are several,
|
||||
|
@ -1748,12 +1750,13 @@ namespace libtorrent
|
|||
mutex::scoped_lock l(m_mutex);
|
||||
|
||||
DLOG(stderr, "[%p] raise_fence: fence: %d num_outstanding: %d\n"
|
||||
, this, m_has_fence, int(m_outstanding_jobs));
|
||||
, static_cast<void*>(this), m_has_fence, int(m_outstanding_jobs));
|
||||
|
||||
if (m_has_fence == 0 && m_outstanding_jobs == 0)
|
||||
{
|
||||
++m_has_fence;
|
||||
DLOG(stderr, "[%p] raise_fence: need posting\n", this);
|
||||
DLOG(stderr, "[%p] raise_fence: need posting\n"
|
||||
, static_cast<void*>(this));
|
||||
|
||||
// the job j is expected to be put on the job queue
|
||||
// after this, without being passed through is_blocked()
|
||||
|
|
|
@ -1558,9 +1558,9 @@ namespace libtorrent
|
|||
std::string names;
|
||||
bool match = false;
|
||||
#endif
|
||||
for (int i = 0; i < sk_GENERAL_NAME_num(gens); ++i)
|
||||
for (int i = 0; i < openssl_num_general_names(gens); ++i)
|
||||
{
|
||||
GENERAL_NAME* gen = sk_GENERAL_NAME_value(gens, i);
|
||||
GENERAL_NAME* gen = openssl_general_name_value(gens, i);
|
||||
if (gen->type != GEN_DNS) continue;
|
||||
ASN1_IA5STRING* domain = gen->d.dNSName;
|
||||
if (domain->type != V_ASN1_IA5STRING || !domain->data || !domain->length) continue;
|
||||
|
@ -1579,8 +1579,9 @@ namespace libtorrent
|
|||
// if we're logging, keep looping over all names,
|
||||
// for completeness of the log
|
||||
continue;
|
||||
#endif
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1619,9 +1620,9 @@ namespace libtorrent
|
|||
debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]"
|
||||
, names.c_str(), match?"yes":"no");
|
||||
return match;
|
||||
#endif
|
||||
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif // BOOST_VERSION
|
||||
|
||||
|
@ -1686,7 +1687,7 @@ namespace libtorrent
|
|||
X509_STORE* cert_store = X509_STORE_new();
|
||||
if (!cert_store)
|
||||
{
|
||||
error_code ec(::ERR_get_error(),
|
||||
ec.assign(::ERR_get_error(),
|
||||
boost::asio::error::get_ssl_category());
|
||||
set_error(ec, error_file_ssl_ctx);
|
||||
pause();
|
||||
|
@ -1694,7 +1695,9 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// wrap the PEM certificate in a BIO, for openssl to read
|
||||
BIO* bp = BIO_new_mem_buf((void*)cert.c_str(), cert.size());
|
||||
BIO* bp = BIO_new_mem_buf(
|
||||
const_cast<void*>(static_cast<void const*>(cert.c_str()))
|
||||
, cert.size());
|
||||
|
||||
// parse the certificate into OpenSSL's internal
|
||||
// representation
|
||||
|
@ -1704,7 +1707,7 @@ namespace libtorrent
|
|||
|
||||
if (!certificate)
|
||||
{
|
||||
error_code ec(::ERR_get_error(),
|
||||
ec.assign(::ERR_get_error(),
|
||||
boost::asio::error::get_ssl_category());
|
||||
X509_STORE_free(cert_store);
|
||||
set_error(ec, error_file_ssl_ctx);
|
||||
|
@ -5884,13 +5887,15 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
std::string password_callback(int length, boost::asio::ssl::context::password_purpose p
|
||||
, std::string pw)
|
||||
{
|
||||
TORRENT_UNUSED(length);
|
||||
namespace {
|
||||
std::string password_callback(int length, boost::asio::ssl::context::password_purpose p
|
||||
, std::string pw)
|
||||
{
|
||||
TORRENT_UNUSED(length);
|
||||
|
||||
if (p != boost::asio::ssl::context::for_reading) return "";
|
||||
return pw;
|
||||
if (p != boost::asio::ssl::context::for_reading) return "";
|
||||
return pw;
|
||||
}
|
||||
}
|
||||
|
||||
// certificate is a filename to a .pem file which is our
|
||||
|
@ -8151,6 +8156,7 @@ namespace libtorrent
|
|||
|
||||
namespace {
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
char const* list_name(int idx)
|
||||
{
|
||||
#define TORRENT_LIST_NAME(n) case aux::session_interface:: n: return #n;
|
||||
|
@ -8169,6 +8175,7 @@ namespace libtorrent
|
|||
#undef TORRENT_LIST_NAME
|
||||
return "";
|
||||
}
|
||||
#endif // TORRENT_DISABLE_LOGGING
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace libtorrent { namespace
|
|||
{
|
||||
ut_metadata_plugin(torrent& t)
|
||||
: m_torrent(t)
|
||||
, m_metadata_progress(0)
|
||||
// , m_metadata_progress(0)
|
||||
, m_metadata_size(0)
|
||||
{
|
||||
// initialize m_metadata_size
|
||||
|
@ -156,7 +156,7 @@ namespace libtorrent { namespace
|
|||
// we should request.
|
||||
// returns -1 if we should hold off the request
|
||||
int metadata_request(bool has_metadata);
|
||||
|
||||
/*
|
||||
// this is called from the peer_connection for
|
||||
// each piece of metadata it receives
|
||||
void metadata_progress(int total_size, int received)
|
||||
|
@ -165,7 +165,7 @@ namespace libtorrent { namespace
|
|||
m_metadata_size = total_size;
|
||||
m_torrent.set_progress_ppm(boost::int64_t(m_metadata_progress) * 1000000 / m_metadata_size);
|
||||
}
|
||||
|
||||
*/
|
||||
void on_piece_pass(int)
|
||||
{
|
||||
// if we became a seed, copy the metadata from
|
||||
|
@ -191,7 +191,7 @@ namespace libtorrent { namespace
|
|||
// it is mutable because it's generated lazily
|
||||
mutable boost::shared_array<char> m_metadata;
|
||||
|
||||
int m_metadata_progress;
|
||||
// int m_metadata_progress;
|
||||
mutable int m_metadata_size;
|
||||
|
||||
struct metadata_piece
|
||||
|
|
10
src/utf8.cpp
10
src/utf8.cpp
|
@ -40,6 +40,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/utf8.hpp"
|
||||
#include "libtorrent/ConvertUTF.h"
|
||||
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-member-function"
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
namespace
|
||||
|
@ -193,5 +199,9 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ static struct utp_logger
|
|||
}
|
||||
} log_file_holder;
|
||||
|
||||
TORRENT_FORMAT(1, 2)
|
||||
void utp_log(char const* fmt, ...)
|
||||
{
|
||||
if (log_file_holder.utp_log_file == NULL) return;
|
||||
|
@ -120,7 +121,7 @@ void set_utp_stream_logging(bool enable) {
|
|||
|
||||
#else
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#if __cplusplus >= 201103L || defined __clang__
|
||||
|
||||
#define UTP_LOG(...) do {} while(false)
|
||||
#define UTP_LOGV(...) do {} while(false)
|
||||
|
@ -811,7 +812,7 @@ void utp_socket_impl::update_mtu_limits()
|
|||
if ((m_cwnd >> 16) < m_mtu) m_cwnd = boost::int64_t(m_mtu) << 16;
|
||||
|
||||
UTP_LOGV("%8p: updating MTU to: %d [%d, %d]\n"
|
||||
, this, m_mtu, m_mtu_floor, m_mtu_ceiling);
|
||||
, static_cast<void*>(this), m_mtu, m_mtu_floor, m_mtu_ceiling);
|
||||
|
||||
// clear the mtu probe sequence number since
|
||||
// it was either dropped or acked
|
||||
|
@ -897,7 +898,7 @@ utp_stream::~utp_stream()
|
|||
{
|
||||
if (m_impl)
|
||||
{
|
||||
UTP_LOGV("%8p: utp_stream destructed\n", m_impl);
|
||||
UTP_LOGV("%8p: utp_stream destructed\n", static_cast<void*>(m_impl));
|
||||
m_impl->destroy();
|
||||
detach_utp_impl(m_impl);
|
||||
}
|
||||
|
@ -931,7 +932,7 @@ void utp_stream::on_read(void* self, size_t bytes_transferred
|
|||
{
|
||||
utp_stream* s = static_cast<utp_stream*>(self);
|
||||
|
||||
UTP_LOGV("%8p: calling read handler read:%d ec:%s kill:%d\n", s->m_impl
|
||||
UTP_LOGV("%8p: calling read handler read:%d ec:%s kill:%d\n", static_cast<void*>(s->m_impl)
|
||||
, int(bytes_transferred), ec.message().c_str(), kill);
|
||||
|
||||
TORRENT_ASSERT(s->m_read_handler);
|
||||
|
@ -954,7 +955,8 @@ void utp_stream::on_write(void* self, size_t bytes_transferred
|
|||
{
|
||||
utp_stream* s = static_cast<utp_stream*>(self);
|
||||
|
||||
UTP_LOGV("%8p: calling write handler written:%d ec:%s kill:%d\n", s->m_impl
|
||||
UTP_LOGV("%8p: calling write handler written:%d ec:%s kill:%d\n"
|
||||
, static_cast<void*>(s->m_impl)
|
||||
, int(bytes_transferred), ec.message().c_str(), kill);
|
||||
|
||||
TORRENT_ASSERT(s->m_write_handler);
|
||||
|
@ -978,7 +980,7 @@ void utp_stream::on_connect(void* self, error_code const& ec, bool kill)
|
|||
TORRENT_ASSERT(s);
|
||||
|
||||
UTP_LOGV("%8p: calling connect handler ec:%s kill:%d\n"
|
||||
, s->m_impl, ec.message().c_str(), kill);
|
||||
, static_cast<void*>(s->m_impl), ec.message().c_str(), kill);
|
||||
|
||||
TORRENT_ASSERT(s->m_connect_handler);
|
||||
s->m_io_service.post(boost::bind<void>(s->m_connect_handler, ec));
|
||||
|
@ -1003,7 +1005,7 @@ void utp_stream::add_read_buffer(void* buf, size_t len)
|
|||
m_impl->m_read_buffer.push_back(utp_socket_impl::iovec_t(buf, len));
|
||||
m_impl->m_read_buffer_size += len;
|
||||
|
||||
UTP_LOGV("%8p: add_read_buffer %d bytes\n", m_impl, int(len));
|
||||
UTP_LOGV("%8p: add_read_buffer %d bytes\n", static_cast<void*>(m_impl), int(len));
|
||||
}
|
||||
|
||||
// this is the wrapper to add a user provided write buffer to the
|
||||
|
@ -1039,7 +1041,7 @@ void utp_stream::add_write_buffer(void const* buf, size_t len)
|
|||
TORRENT_ASSERT(m_impl->m_write_buffer_size == write_buffer_size);
|
||||
#endif
|
||||
|
||||
UTP_LOGV("%8p: add_write_buffer %d bytes\n", m_impl, int(len));
|
||||
UTP_LOGV("%8p: add_write_buffer %d bytes\n", static_cast<void*>(m_impl), int(len));
|
||||
}
|
||||
|
||||
// this is called when all user provided read buffers have been added
|
||||
|
@ -1058,7 +1060,7 @@ void utp_stream::issue_read()
|
|||
if (m_impl->test_socket_state()) return;
|
||||
|
||||
UTP_LOGV("%8p: new read handler. %d bytes in buffer\n"
|
||||
, m_impl, m_impl->m_receive_buffer_size);
|
||||
, static_cast<void*>(m_impl), m_impl->m_receive_buffer_size);
|
||||
|
||||
// so, the client wants to read. If we already
|
||||
// have some data in the read buffer, move it into the
|
||||
|
@ -1142,12 +1144,12 @@ size_t utp_stream::read_some(bool clear_buffers)
|
|||
|| m_impl->m_read_buffer.empty());
|
||||
|
||||
UTP_LOGV("%8p: %d packets moved from buffer to user space (%d bytes)\n"
|
||||
, m_impl, pop_packets, int(ret));
|
||||
, static_cast<void*>(m_impl), pop_packets, int(ret));
|
||||
|
||||
if (clear_buffers)
|
||||
{
|
||||
m_impl->m_read_buffer_size = 0;
|
||||
m_impl->m_read_buffer.clear();
|
||||
m_impl->m_read_buffer_size = 0;
|
||||
m_impl->m_read_buffer.clear();
|
||||
}
|
||||
TORRENT_ASSERT(ret > 0 || m_impl->m_null_buffers);
|
||||
return ret;
|
||||
|
@ -1158,7 +1160,7 @@ size_t utp_stream::read_some(bool clear_buffers)
|
|||
void utp_stream::issue_write()
|
||||
{
|
||||
UTP_LOGV("%8p: new write handler. %d bytes to write\n"
|
||||
, m_impl, m_impl->m_write_buffer_size);
|
||||
, static_cast<void*>(m_impl), m_impl->m_write_buffer_size);
|
||||
|
||||
TORRENT_ASSERT(m_impl->m_write_buffer_size > 0);
|
||||
TORRENT_ASSERT(m_impl->m_write_handler == false);
|
||||
|
@ -1207,7 +1209,7 @@ utp_socket_impl::~utp_socket_impl()
|
|||
|
||||
m_sm->inc_stats_counter(counters::num_utp_idle + m_state, -1);
|
||||
|
||||
UTP_LOGV("%8p: destroying utp socket state\n", this);
|
||||
UTP_LOGV("%8p: destroying utp socket state\n", static_cast<void*>(this));
|
||||
|
||||
// free any buffers we're holding
|
||||
for (boost::uint16_t i = m_inbuf.cursor(), end((m_inbuf.cursor()
|
||||
|
@ -1255,7 +1257,7 @@ bool utp_socket_impl::should_delete() const
|
|||
|
||||
if (ret)
|
||||
{
|
||||
UTP_LOGV("%8p: should_delete() = true\n", this);
|
||||
UTP_LOGV("%8p: should_delete() = true\n", static_cast<void const*>(this));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1271,7 +1273,7 @@ void utp_socket_impl::maybe_trigger_receive_callback()
|
|||
if (m_null_buffers && m_receive_buffer_size == 0) return;
|
||||
else if (!m_null_buffers && m_read == 0) return;
|
||||
|
||||
UTP_LOGV("%8p: calling read handler read:%d\n", this, m_read);
|
||||
UTP_LOGV("%8p: calling read handler read:%d\n", static_cast<void*>(this), m_read);
|
||||
m_read_handler = false;
|
||||
utp_stream::on_read(m_userdata, m_read, m_error, false);
|
||||
m_read = 0;
|
||||
|
@ -1286,7 +1288,7 @@ void utp_socket_impl::maybe_trigger_send_callback()
|
|||
// nothing has been written or there's no outstanding write operation
|
||||
if (m_written == 0 || m_write_handler == false) return;
|
||||
|
||||
UTP_LOGV("%8p: calling write handler written:%d\n", this, m_written);
|
||||
UTP_LOGV("%8p: calling write handler written:%d\n", static_cast<void*>(this), m_written);
|
||||
|
||||
m_write_handler = false;
|
||||
utp_stream::on_write(m_userdata, m_written, m_error, false);
|
||||
|
@ -1299,7 +1301,7 @@ void utp_socket_impl::set_close_reason(boost::uint16_t code)
|
|||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: set_close_reason: %d\n"
|
||||
, this, int(m_close_reason));
|
||||
, static_cast<void*>(this), int(m_close_reason));
|
||||
#endif
|
||||
m_close_reason = code;
|
||||
}
|
||||
|
@ -1310,7 +1312,7 @@ bool utp_socket_impl::destroy()
|
|||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: destroy state:%s (close-reason: %d)\n"
|
||||
, this, socket_state_names[m_state], int(m_close_reason));
|
||||
, static_cast<void*>(this), socket_state_names[m_state], int(m_close_reason));
|
||||
#endif
|
||||
|
||||
if (m_userdata == 0) return false;
|
||||
|
@ -1334,7 +1336,7 @@ bool utp_socket_impl::destroy()
|
|||
{
|
||||
set_state(UTP_STATE_DELETE);
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: state:%s\n", this, socket_state_names[m_state]);
|
||||
UTP_LOGV("%8p: state:%s\n", static_cast<void*>(this), socket_state_names[m_state]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1347,7 +1349,7 @@ void utp_socket_impl::detach()
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
UTP_LOGV("%8p: detach()\n", this);
|
||||
UTP_LOGV("%8p: detach()\n", static_cast<void*>(this));
|
||||
m_attached = false;
|
||||
}
|
||||
|
||||
|
@ -1389,7 +1391,7 @@ void utp_socket_impl::send_syn()
|
|||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: send_syn seq_nr:%d id:%d target:%s\n"
|
||||
, this, int(m_seq_nr), int(m_recv_id)
|
||||
, static_cast<void*>(this), int(m_seq_nr), int(m_recv_id)
|
||||
, print_endpoint(udp::endpoint(m_remote_address, m_port)).c_str());
|
||||
#endif
|
||||
|
||||
|
@ -1400,7 +1402,7 @@ void utp_socket_impl::send_syn()
|
|||
if (ec == error::would_block || ec == error::try_again)
|
||||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: socket stalled\n", this);
|
||||
UTP_LOGV("%8p: socket stalled\n", static_cast<void*>(this));
|
||||
#endif
|
||||
if (!m_stalled)
|
||||
{
|
||||
|
@ -1430,7 +1432,7 @@ void utp_socket_impl::send_syn()
|
|||
TORRENT_ASSERT(!m_error);
|
||||
set_state(UTP_STATE_SYN_SENT);
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: state:%s\n", this, socket_state_names[m_state]);
|
||||
UTP_LOGV("%8p: state:%s\n", static_cast<void*>(this), socket_state_names[m_state]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1440,7 +1442,7 @@ void utp_socket_impl::send_syn()
|
|||
void utp_socket_impl::writable()
|
||||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: writable\n", this);
|
||||
UTP_LOGV("%8p: writable\n", static_cast<void*>(this));
|
||||
#endif
|
||||
if (should_delete()) return;
|
||||
|
||||
|
@ -1460,7 +1462,7 @@ void utp_socket_impl::send_fin()
|
|||
set_state(UTP_STATE_FIN_SENT);
|
||||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: state:%s\n", this, socket_state_names[m_state]);
|
||||
UTP_LOGV("%8p: state:%s\n", static_cast<void*>(this), socket_state_names[m_state]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1481,7 +1483,7 @@ void utp_socket_impl::send_reset(utp_header const* ph)
|
|||
total_microseconds(now.time_since_epoch()) & 0xffffffff);
|
||||
|
||||
UTP_LOGV("%8p: send_reset seq_nr:%d id:%d ack_nr:%d\n"
|
||||
, this, int(h.seq_nr), int(m_send_id), int(ph->seq_nr));
|
||||
, static_cast<void*>(this), int(h.seq_nr), int(m_send_id), int(ph->seq_nr));
|
||||
|
||||
// ignore errors here
|
||||
error_code ec;
|
||||
|
@ -1502,7 +1504,7 @@ void utp_socket_impl::parse_close_reason(boost::uint8_t const* ptr, int size)
|
|||
boost::uint16_t incoming_close_reason = detail::read_uint16(ptr);
|
||||
|
||||
UTP_LOGV("%8p: incoming close_reason: %d\n"
|
||||
, this, int(incoming_close_reason));
|
||||
, static_cast<void*>(this), int(incoming_close_reason));
|
||||
|
||||
if (m_userdata == 0) return;
|
||||
|
||||
|
@ -1534,7 +1536,7 @@ void utp_socket_impl::parse_sack(boost::uint16_t packet_ack, boost::uint8_t cons
|
|||
}
|
||||
}
|
||||
UTP_LOGV("%8p: got SACK first:%d %s our_seq_nr:%u\n"
|
||||
, this, ack_nr, bitmask.c_str(), m_seq_nr);
|
||||
, static_cast<void*>(this), ack_nr, bitmask.c_str(), m_seq_nr);
|
||||
#endif
|
||||
|
||||
// the number of acked packets past the fast re-send sequence number
|
||||
|
@ -1566,7 +1568,7 @@ void utp_socket_impl::parse_sack(boost::uint16_t packet_ack, boost::uint8_t cons
|
|||
*acked_bytes += p->size - p->header_size;
|
||||
// each ACKed packet counts as a duplicate ack
|
||||
UTP_LOGV("%8p: duplicate_acks:%u fast_resend_seq_nr:%u\n"
|
||||
, this, m_duplicate_acks, m_fast_resend_seq_nr);
|
||||
, static_cast<void*>(this), m_duplicate_acks, m_fast_resend_seq_nr);
|
||||
ack_packet(p, now, min_rtt, ack_nr);
|
||||
}
|
||||
else
|
||||
|
@ -1670,7 +1672,7 @@ void utp_socket_impl::subscribe_drained()
|
|||
|
||||
if (m_subscribe_drained) return;
|
||||
|
||||
UTP_LOGV("%8p: subscribe drained\n", this);
|
||||
UTP_LOGV("%8p: subscribe drained\n", static_cast<void*>(this));
|
||||
m_subscribe_drained = true;
|
||||
m_sm->subscribe_drained(this);
|
||||
}
|
||||
|
@ -1681,7 +1683,7 @@ void utp_socket_impl::defer_ack()
|
|||
|
||||
if (m_deferred_ack) return;
|
||||
|
||||
UTP_LOGV("%8p: defer ack\n", this);
|
||||
UTP_LOGV("%8p: defer ack\n", static_cast<void*>(this));
|
||||
m_deferred_ack = true;
|
||||
m_sm->defer_ack(this);
|
||||
}
|
||||
|
@ -1702,7 +1704,7 @@ void utp_socket_impl::remove_sack_header(packet* p)
|
|||
|| h->extension == utp_close_reason);
|
||||
|
||||
UTP_LOGV("%8p: removing SACK header, %d bytes\n"
|
||||
, this, sack_size + 2);
|
||||
, static_cast<void*>(this), sack_size + 2);
|
||||
|
||||
TORRENT_ASSERT(p->size >= p->header_size);
|
||||
TORRENT_ASSERT(p->header_size >= sizeof(utp_header) + sack_size + 2);
|
||||
|
@ -1815,7 +1817,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
|
||||
UTP_LOGV("%8p: no space in window send_buffer_size:%d cwnd:%d "
|
||||
"adv_wnd:%d in-flight:%d mtu:%d\n"
|
||||
, this, m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, static_cast<void*>(this), m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, m_adv_wnd, m_bytes_in_flight, m_mtu);
|
||||
|
||||
if (!force)
|
||||
|
@ -1824,7 +1826,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
UTP_LOGV("%8p: skipping send seq_nr:%d ack_nr:%d "
|
||||
"id:%d target:%s header_size:%d error:%s send_buffer_size:%d cwnd:%d "
|
||||
"adv_wnd:%d in-flight:%d mtu:%d\n"
|
||||
, this, int(m_seq_nr), int(m_ack_nr)
|
||||
, static_cast<void*>(this), int(m_seq_nr), int(m_ack_nr)
|
||||
, m_send_id, print_endpoint(udp::endpoint(m_remote_address, m_port)).c_str()
|
||||
, header_size, m_error.message().c_str(), m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, m_adv_wnd, m_bytes_in_flight, m_mtu);
|
||||
|
@ -1841,7 +1843,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
UTP_LOGV("%8p: skipping send (no payload and no force) seq_nr:%d ack_nr:%d "
|
||||
"id:%d target:%s header_size:%d error:%s send_buffer_size:%d cwnd:%d "
|
||||
"adv_wnd:%d in-flight:%d mtu:%d\n"
|
||||
, this, int(m_seq_nr), int(m_ack_nr)
|
||||
, static_cast<void*>(this), int(m_seq_nr), int(m_ack_nr)
|
||||
, m_send_id, print_endpoint(udp::endpoint(m_remote_address, m_port)).c_str()
|
||||
, header_size, m_error.message().c_str(), m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, m_adv_wnd, m_bytes_in_flight, m_mtu);
|
||||
|
@ -1889,7 +1891,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
p = reinterpret_cast<packet*>(TORRENT_ALLOCA(char, sizeof(packet) + packet_size
|
||||
+ sizeof(packet*) - 1));
|
||||
p = reinterpret_cast<packet*>(align_pointer(p));
|
||||
UTP_LOGV("%8p: allocating %d bytes on the stack\n", this, packet_size);
|
||||
UTP_LOGV("%8p: allocating %d bytes on the stack\n", static_cast<void*>(this), packet_size);
|
||||
p->allocated = packet_size;
|
||||
}
|
||||
|
||||
|
@ -1948,7 +1950,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
p->size += size_left;
|
||||
|
||||
UTP_LOGV("%8p: NAGLE appending %d bytes to nagle packet. new size: %d allocated: %d\n"
|
||||
, this, size_left, p->size, p->allocated);
|
||||
, static_cast<void*>(this), size_left, p->size, p->allocated);
|
||||
|
||||
// did we fill up the whole mtu?
|
||||
// if we didn't, we may still send it if there's
|
||||
|
@ -1997,7 +1999,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
// payload
|
||||
UTP_LOGV("%8p: NAGLE not enough payload send_buffer_size:%d cwnd:%d "
|
||||
"adv_wnd:%d in-flight:%d mtu:%d\n"
|
||||
, this, m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, static_cast<void*>(this), m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, m_adv_wnd, m_bytes_in_flight, m_mtu);
|
||||
TORRENT_ASSERT(m_nagle_packet == NULL);
|
||||
TORRENT_ASSERT(h->seq_nr == m_seq_nr);
|
||||
|
@ -2039,7 +2041,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
"id:%d target:%s size:%d error:%s send_buffer_size:%d cwnd:%d "
|
||||
"adv_wnd:%d in-flight:%d mtu:%d timestamp:%u time_diff:%u "
|
||||
"mtu_probe:%d extension:%d\n"
|
||||
, this, int(h->seq_nr), int(h->ack_nr), packet_type_names[h->get_type()]
|
||||
, static_cast<void*>(this), int(h->seq_nr), int(h->ack_nr), packet_type_names[h->get_type()]
|
||||
, m_send_id, print_endpoint(udp::endpoint(m_remote_address, m_port)).c_str()
|
||||
, p->size, m_error.message().c_str(), m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, m_adv_wnd, m_bytes_in_flight, m_mtu, boost::uint32_t(h->timestamp_microseconds)
|
||||
|
@ -2058,7 +2060,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
if (ec == error::message_size)
|
||||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: error sending packet: %s\n", this, ec.message().c_str());
|
||||
UTP_LOGV("%8p: error sending packet: %s\n", static_cast<void*>(this), ec.message().c_str());
|
||||
#endif
|
||||
// if we fail even though this is not a probe, we're screwed
|
||||
// since we'd have to repacketize
|
||||
|
@ -2074,7 +2076,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
ec.clear();
|
||||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: re-sending\n", this);
|
||||
UTP_LOGV("%8p: re-sending\n", static_cast<void*>(this));
|
||||
#endif
|
||||
m_sm->send_packet(udp::endpoint(m_remote_address, m_port)
|
||||
, reinterpret_cast<char const*>(h), p->size, ec, 0);
|
||||
|
@ -2083,7 +2085,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
if (ec == error::would_block || ec == error::try_again)
|
||||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: socket stalled\n", this);
|
||||
UTP_LOGV("%8p: socket stalled\n", static_cast<void*>(this));
|
||||
#endif
|
||||
if (!m_stalled)
|
||||
{
|
||||
|
@ -2253,7 +2255,7 @@ bool utp_socket_impl::resend_packet(packet* p, bool fast_resend)
|
|||
UTP_LOGV("%8p: re-sending packet seq_nr:%d ack_nr:%d type:%s "
|
||||
"id:%d target:%s size:%d error:%s send_buffer_size:%d cwnd:%d "
|
||||
"adv_wnd:%d in-flight:%d mtu:%d timestamp:%u time_diff:%u\n"
|
||||
, this, int(h->seq_nr), int(h->ack_nr), packet_type_names[h->get_type()]
|
||||
, static_cast<void*>(this), int(h->seq_nr), int(h->ack_nr), packet_type_names[h->get_type()]
|
||||
, m_send_id, print_endpoint(udp::endpoint(m_remote_address, m_port)).c_str()
|
||||
, p->size, ec.message().c_str(), m_write_buffer_size, int(m_cwnd >> 16)
|
||||
, m_adv_wnd, m_bytes_in_flight, m_mtu, boost::uint32_t(h->timestamp_microseconds)
|
||||
|
@ -2263,7 +2265,7 @@ bool utp_socket_impl::resend_packet(packet* p, bool fast_resend)
|
|||
if (ec == error::would_block || ec == error::try_again)
|
||||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: socket stalled\n", this);
|
||||
UTP_LOGV("%8p: socket stalled\n", static_cast<void*>(this));
|
||||
#endif
|
||||
if (!m_stalled)
|
||||
{
|
||||
|
@ -2303,7 +2305,7 @@ void utp_socket_impl::experienced_loss(int seq_nr)
|
|||
// cut window size in 2
|
||||
m_cwnd = (std::max)(m_cwnd * m_sm->loss_multiplier() / 100, boost::int64_t(m_mtu << 16));
|
||||
m_loss_seq_nr = m_seq_nr;
|
||||
UTP_LOGV("%8p: Lost packet %d caused cwnd cut\n", this, seq_nr);
|
||||
UTP_LOGV("%8p: Lost packet %d caused cwnd cut\n", static_cast<void*>(this), seq_nr);
|
||||
|
||||
// if we happen to be in slow-start mode, we need to leave it
|
||||
// note that we set ssthres to the window size _after_ reducing it. Next slow
|
||||
|
@ -2312,7 +2314,7 @@ void utp_socket_impl::experienced_loss(int seq_nr)
|
|||
{
|
||||
m_ssthres = m_cwnd >> 16;
|
||||
m_slow_start = false;
|
||||
UTP_LOGV("%8p: experienced loss, slow_start -> 0\n", this);
|
||||
UTP_LOGV("%8p: experienced loss, slow_start -> 0\n", static_cast<void*>(this));
|
||||
}
|
||||
|
||||
// the window size could go below one MMS here, if it does,
|
||||
|
@ -2405,7 +2407,7 @@ void utp_socket_impl::ack_packet(packet* p, time_point const& receive_time
|
|||
}
|
||||
|
||||
UTP_LOGV("%8p: acked packet %d (%d bytes) (rtt:%u)\n"
|
||||
, this, seq_nr, p->size - p->header_size, rtt / 1000);
|
||||
, static_cast<void*>(this), seq_nr, p->size - p->header_size, rtt / 1000);
|
||||
|
||||
m_rtt.add_sample(rtt / 1000);
|
||||
if (rtt < min_rtt) min_rtt = rtt;
|
||||
|
@ -2421,7 +2423,7 @@ void utp_socket_impl::incoming(boost::uint8_t const* buf, int size, packet* p
|
|||
|
||||
while (!m_read_buffer.empty())
|
||||
{
|
||||
UTP_LOGV("%8p: incoming: have user buffer (%d)\n", this, m_read_buffer_size);
|
||||
UTP_LOGV("%8p: incoming: have user buffer (%d)\n", static_cast<void*>(this), m_read_buffer_size);
|
||||
if (p)
|
||||
{
|
||||
buf = p->buf + p->header_size;
|
||||
|
@ -2435,7 +2437,7 @@ void utp_socket_impl::incoming(boost::uint8_t const* buf, int size, packet* p
|
|||
target->buf = reinterpret_cast<boost::uint8_t*>(target->buf) + to_copy;
|
||||
target->len -= to_copy;
|
||||
buf += to_copy;
|
||||
UTP_LOGV("%8p: copied %d bytes into user receive buffer\n", this, to_copy);
|
||||
UTP_LOGV("%8p: copied %d bytes into user receive buffer\n", static_cast<void*>(this), to_copy);
|
||||
TORRENT_ASSERT(m_read_buffer_size >= to_copy);
|
||||
m_read_buffer_size -= to_copy;
|
||||
size -= to_copy;
|
||||
|
@ -2468,7 +2470,7 @@ void utp_socket_impl::incoming(boost::uint8_t const* buf, int size, packet* p
|
|||
m_receive_buffer.push_back(p);
|
||||
m_receive_buffer_size += p->size - p->header_size;
|
||||
|
||||
UTP_LOGV("%8p: incoming: saving packet in receive buffer (%d)\n", this, m_receive_buffer_size);
|
||||
UTP_LOGV("%8p: incoming: saving packet in receive buffer (%d)\n", static_cast<void*>(this), m_receive_buffer_size);
|
||||
|
||||
check_receive_buffers();
|
||||
}
|
||||
|
@ -2508,7 +2510,8 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
{
|
||||
// What?! We've already received a FIN and everything up
|
||||
// to it has been acked. Ignore this packet
|
||||
UTP_LOG("%8p: ERROR: ignoring packet on shut down socket\n", this);
|
||||
UTP_LOG("%8p: ERROR: ignoring packet on shut down socket\n"
|
||||
, static_cast<void*>(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2521,7 +2524,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
// more data packets
|
||||
UTP_LOG("%8p: ERROR: our advertized window is not honored. "
|
||||
"recv_buf: %d buffered_in: %d max_size: %d\n"
|
||||
, this, m_receive_buffer_size, m_buffered_incoming_bytes, m_in_buf_size);
|
||||
, static_cast<void*>(this), m_receive_buffer_size, m_buffered_incoming_bytes, m_in_buf_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2531,7 +2534,8 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
|
||||
if (m_buffered_incoming_bytes + m_receive_buffer_size + payload_size > m_in_buf_size)
|
||||
{
|
||||
UTP_LOGV("%8p: other end is not honoring our advertised window, dropping packet\n", this);
|
||||
UTP_LOGV("%8p: other end is not honoring our advertised window, dropping packet\n"
|
||||
, static_cast<void*>(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2544,7 +2548,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
TORRENT_ASSERT(m_inbuf.at(m_ack_nr) == 0);
|
||||
|
||||
UTP_LOGV("%8p: remove inbuf: %d (%d)\n"
|
||||
, this, m_ack_nr, int(m_inbuf.size()));
|
||||
, static_cast<void*>(this), m_ack_nr, int(m_inbuf.size()));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -2560,7 +2564,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
m_ack_nr = next_ack_nr;
|
||||
|
||||
UTP_LOGV("%8p: reordered remove inbuf: %d (%d)\n"
|
||||
, this, m_ack_nr, int(m_inbuf.size()));
|
||||
, static_cast<void*>(this), m_ack_nr, int(m_inbuf.size()));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2573,7 +2577,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
if (!compare_less_wrap(m_ack_nr, ph->seq_nr, ACK_MASK))
|
||||
{
|
||||
UTP_LOGV("%8p: already received seq_nr: %d\n"
|
||||
, this, int(ph->seq_nr));
|
||||
, static_cast<void*>(this), int(ph->seq_nr));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2581,14 +2585,14 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
if (m_inbuf.at(ph->seq_nr))
|
||||
{
|
||||
UTP_LOGV("%8p: already received seq_nr: %d\n"
|
||||
, this, int(ph->seq_nr));
|
||||
, static_cast<void*>(this), int(ph->seq_nr));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_buffered_incoming_bytes + m_receive_buffer_size + payload_size > m_in_buf_size)
|
||||
{
|
||||
UTP_LOGV("%8p: other end is not honoring our advertised window, dropping packet %d\n"
|
||||
, this, int(ph->seq_nr));
|
||||
, static_cast<void*>(this), int(ph->seq_nr));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2606,7 +2610,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
m_buffered_incoming_bytes += p->size;
|
||||
|
||||
UTP_LOGV("%8p: out of order. insert inbuf: %d (%d) m_ack_nr: %d\n"
|
||||
, this, int(ph->seq_nr), int(m_inbuf.size()), m_ack_nr);
|
||||
, static_cast<void*>(this), int(ph->seq_nr), int(m_inbuf.size()), m_ack_nr);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -2628,14 +2632,14 @@ bool utp_socket_impl::test_socket_state()
|
|||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: state:%s error:%s\n"
|
||||
, this, socket_state_names[m_state], m_error.message().c_str());
|
||||
, static_cast<void*>(this), socket_state_names[m_state], m_error.message().c_str());
|
||||
#endif
|
||||
|
||||
if (cancel_handlers(m_error, true))
|
||||
{
|
||||
set_state(UTP_STATE_DELETE);
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: state:%s\n", this, socket_state_names[m_state]);
|
||||
UTP_LOGV("%8p: state:%s\n", static_cast<void*>(this), socket_state_names[m_state]);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -2670,7 +2674,7 @@ void utp_socket_impl::init_mtu(int link_mtu, int utp_mtu)
|
|||
if ((m_cwnd >> 16) < m_mtu) m_cwnd = boost::int64_t(m_mtu) << 16;
|
||||
|
||||
UTP_LOGV("%8p: initializing MTU to: %d [%d, %d]\n"
|
||||
, this, m_mtu, m_mtu_floor, m_mtu_ceiling);
|
||||
, static_cast<void*>(this), m_mtu, m_mtu_floor, m_mtu_ceiling);
|
||||
}
|
||||
|
||||
// return false if this is an invalid packet
|
||||
|
@ -2686,7 +2690,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
if (ph->get_version() != 1)
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: incoming packet version:%d (ignored)\n"
|
||||
, this, int(ph->get_version()));
|
||||
, static_cast<void*>(this), int(ph->get_version()));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return false;
|
||||
}
|
||||
|
@ -2695,7 +2699,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
if (ph->get_type() != ST_SYN && ph->connection_id != m_recv_id)
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: incoming packet id:%d expected:%d (ignored)\n"
|
||||
, this, int(ph->connection_id), int(m_recv_id));
|
||||
, static_cast<void*>(this), int(ph->connection_id), int(m_recv_id));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return false;
|
||||
}
|
||||
|
@ -2703,7 +2707,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
if (ph->get_type() >= NUM_TYPES)
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: incoming packet type:%d (ignored)\n"
|
||||
, this, int(ph->get_type()));
|
||||
, static_cast<void*>(this), int(ph->get_type()));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return false;
|
||||
}
|
||||
|
@ -2716,7 +2720,8 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
|
||||
if (m_state != UTP_STATE_NONE && ph->get_type() == ST_SYN)
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: incoming packet type:ST_SYN (ignored)\n", this);
|
||||
UTP_LOG("%8p: ERROR: incoming packet type:ST_SYN (ignored)\n"
|
||||
, static_cast<void*>(this));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return true;
|
||||
}
|
||||
|
@ -2740,7 +2745,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
their_delay = m_their_delay_hist.add_sample(m_reply_micro, step);
|
||||
int base_change = m_their_delay_hist.base() - prev_base;
|
||||
UTP_LOGV("%8p: their_delay::add_sample:%u prev_base:%u new_base:%u\n"
|
||||
, this, m_reply_micro, prev_base, m_their_delay_hist.base());
|
||||
, static_cast<void*>(this), m_reply_micro, prev_base, m_their_delay_hist.base());
|
||||
|
||||
if (prev_base && base_change < 0 && base_change > -10000 && m_delay_hist.initialized())
|
||||
{
|
||||
|
@ -2751,7 +2756,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
}
|
||||
|
||||
UTP_LOGV("%8p: incoming packet reply_micro:%u base_change:%d\n"
|
||||
, this, m_reply_micro, prev_base ? base_change : 0);
|
||||
, static_cast<void*>(this), m_reply_micro, prev_base ? base_change : 0);
|
||||
}
|
||||
|
||||
// is this ACK valid? If the other end is ACKing
|
||||
|
@ -2776,7 +2781,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
{
|
||||
UTP_LOG("%8p: ERROR: incoming packet ack_nr:%d our seq_nr:%d our "
|
||||
"acked_seq_nr:%d (ignored)\n"
|
||||
, this, int(ph->ack_nr), m_seq_nr, m_acked_seq_nr);
|
||||
, static_cast<void*>(this), int(ph->ack_nr), m_seq_nr, m_acked_seq_nr);
|
||||
m_sm->inc_stats_counter(counters::utp_redundant_pkts_in);
|
||||
return true;
|
||||
}
|
||||
|
@ -2798,7 +2803,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
{
|
||||
// we've already received this packet
|
||||
UTP_LOGV("%8p: incoming packet seq_nr:%d our ack_nr:%d (ignored)\n"
|
||||
, this, int(ph->seq_nr), m_ack_nr);
|
||||
, static_cast<void*>(this), int(ph->seq_nr), m_ack_nr);
|
||||
m_sm->inc_stats_counter(counters::utp_redundant_pkts_in);
|
||||
return true;
|
||||
}
|
||||
|
@ -2810,7 +2815,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOG("%8p: ERROR: incoming packet type: %s seq_nr:%d eof_seq_nr:%d (ignored)\n"
|
||||
, this, packet_type_names[ph->get_type()], int(ph->seq_nr), m_eof_seq_nr);
|
||||
, static_cast<void*>(this), packet_type_names[ph->get_type()], int(ph->seq_nr), m_eof_seq_nr);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -2828,7 +2833,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
// packets. Neither is very likely, and it should be OK
|
||||
// to drop the timestamp information.
|
||||
UTP_LOG("%8p: ERROR: incoming packet seq_nr:%d our ack_nr:%d (ignored)\n"
|
||||
, this, int(ph->seq_nr), m_ack_nr);
|
||||
, static_cast<void*>(this), int(ph->seq_nr), m_ack_nr);
|
||||
m_sm->inc_stats_counter(counters::utp_redundant_pkts_in);
|
||||
return true;
|
||||
}
|
||||
|
@ -2838,10 +2843,10 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
if (compare_less_wrap(cmp_seq_nr, ph->ack_nr, ACK_MASK))
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: invalid RESET packet, ack_nr:%d our seq_nr:%d (ignored)\n"
|
||||
, this, int(ph->ack_nr), m_seq_nr);
|
||||
, static_cast<void*>(this), int(ph->ack_nr), m_seq_nr);
|
||||
return true;
|
||||
}
|
||||
UTP_LOGV("%8p: incoming packet type:RESET\n", this);
|
||||
UTP_LOGV("%8p: incoming packet type:RESET\n", static_cast<void*>(this));
|
||||
m_error = boost::asio::error::connection_reset;
|
||||
set_state(UTP_STATE_ERROR_WAIT);
|
||||
test_socket_state();
|
||||
|
@ -2854,7 +2859,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
m_num_timeouts = 0;
|
||||
m_timeout = receive_time + milliseconds(packet_timeout());
|
||||
UTP_LOGV("%8p: updating timeout to: now + %d\n"
|
||||
, this, packet_timeout());
|
||||
, static_cast<void*>(this), packet_timeout());
|
||||
|
||||
// the test for INT_MAX here is a work-around for a bug in uTorrent where
|
||||
// it's sometimes sent as INT_MAX when it is in fact uninitialized
|
||||
|
@ -2925,7 +2930,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
// but the packet is too short
|
||||
if (ptr - buf + 2 > size)
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: invalid extension header\n", this);
|
||||
UTP_LOG("%8p: ERROR: invalid extension header\n", static_cast<void*>(this));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return true;
|
||||
}
|
||||
|
@ -2934,14 +2939,14 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
if (len < 0)
|
||||
{
|
||||
UTP_LOGV("%8p: invalid extension length:%d packet:%d\n"
|
||||
, this, len, int(ptr - buf));
|
||||
, static_cast<void*>(this), len, int(ptr - buf));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return true;
|
||||
}
|
||||
if (ptr - buf + len > ptrdiff_t(size))
|
||||
{
|
||||
UTP_LOG("%8p: ERROR: invalid extension header size:%d packet:%d\n"
|
||||
, this, len, int(ptr - buf));
|
||||
, static_cast<void*>(this), len, int(ptr - buf));
|
||||
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
|
||||
return true;
|
||||
}
|
||||
|
@ -2967,7 +2972,8 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
{
|
||||
// LOSS
|
||||
|
||||
UTP_LOGV("%8p: Packet %d lost. (%d duplicate acks, trigger fast-resend)\n", this, m_fast_resend_seq_nr, m_duplicate_acks);
|
||||
UTP_LOGV("%8p: Packet %d lost. (%d duplicate acks, trigger fast-resend)\n"
|
||||
, static_cast<void*>(this), m_fast_resend_seq_nr, m_duplicate_acks);
|
||||
|
||||
// resend the lost packet
|
||||
packet* p = m_outbuf.at(m_fast_resend_seq_nr);
|
||||
|
@ -2993,7 +2999,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: incoming packet seq_nr:%d ack_nr:%d type:%s id:%d size:%d timestampdiff:%u timestamp:%u "
|
||||
"our ack_nr:%d our seq_nr:%d our acked_seq_nr:%d our state:%s\n"
|
||||
, this, int(ph->seq_nr), int(ph->ack_nr), packet_type_names[ph->get_type()]
|
||||
, static_cast<void*>(this), int(ph->seq_nr), int(ph->ack_nr), packet_type_names[ph->get_type()]
|
||||
, int(ph->connection_id), payload_size, boost::uint32_t(ph->timestamp_difference_microseconds)
|
||||
, boost::uint32_t(ph->timestamp_microseconds), m_ack_nr, m_seq_nr, m_acked_seq_nr, socket_state_names[m_state]);
|
||||
#endif
|
||||
|
@ -3004,7 +3010,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
if (ph->seq_nr == ((m_ack_nr + 1) & ACK_MASK)
|
||||
|| ph->seq_nr == m_ack_nr)
|
||||
{
|
||||
UTP_LOGV("%8p: FIN received in order\n", this);
|
||||
UTP_LOGV("%8p: FIN received in order\n", static_cast<void*>(this));
|
||||
|
||||
// The FIN arrived in order, nothing else is in the
|
||||
// reorder buffer.
|
||||
|
@ -3030,7 +3036,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
|
||||
if (m_eof)
|
||||
{
|
||||
UTP_LOGV("%8p: duplicate FIN packet (ignoring)\n", this);
|
||||
UTP_LOGV("%8p: duplicate FIN packet (ignoring)\n", static_cast<void*>(this));
|
||||
return true;
|
||||
}
|
||||
m_eof = true;
|
||||
|
@ -3063,7 +3069,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: received ST_SYN state:%s seq_nr:%d ack_nr:%d\n"
|
||||
, this, socket_state_names[m_state], m_seq_nr, m_ack_nr);
|
||||
, static_cast<void*>(this), socket_state_names[m_state], m_seq_nr, m_ack_nr);
|
||||
#endif
|
||||
TORRENT_ASSERT(m_send_id == ph->connection_id);
|
||||
TORRENT_ASSERT(m_recv_id == ((m_send_id + 1) & 0xffff));
|
||||
|
@ -3074,7 +3080,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOG("%8p: ERROR: type:%s state:%s (ignored)\n"
|
||||
, this, packet_type_names[ph->get_type()], socket_state_names[m_state]);
|
||||
, static_cast<void*>(this), packet_type_names[ph->get_type()], socket_state_names[m_state]);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -3086,7 +3092,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: incorrect ack_nr (%d) waiting for %d\n"
|
||||
, this, int(ph->ack_nr), (m_seq_nr - 1) & ACK_MASK);
|
||||
, static_cast<void*>(this), int(ph->ack_nr), (m_seq_nr - 1) & ACK_MASK);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -3094,7 +3100,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
TORRENT_ASSERT(!m_error);
|
||||
set_state(UTP_STATE_CONNECTED);
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: state:%s\n", this, socket_state_names[m_state]);
|
||||
UTP_LOGV("%8p: state:%s\n", static_cast<void*>(this), socket_state_names[m_state]);
|
||||
#endif
|
||||
|
||||
// only progress our ack_nr on ST_DATA messages
|
||||
|
@ -3108,7 +3114,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
// notify the client that the socket connected
|
||||
if (m_connect_handler)
|
||||
{
|
||||
UTP_LOGV("%8p: calling connect handler\n", this);
|
||||
UTP_LOGV("%8p: calling connect handler\n", static_cast<void*>(this));
|
||||
m_connect_handler = false;
|
||||
utp_stream::on_connect(m_userdata, m_error, false);
|
||||
}
|
||||
|
@ -3174,7 +3180,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
// from our side.
|
||||
if (m_eof && m_ack_nr == ((m_eof_seq_nr - 1) & ACK_MASK))
|
||||
{
|
||||
UTP_LOGV("%8p: incoming stream consumed\n", this);
|
||||
UTP_LOGV("%8p: incoming stream consumed\n", static_cast<void*>(this));
|
||||
|
||||
// This transitions to the UTP_STATE_FIN_SENT state.
|
||||
send_fin();
|
||||
|
@ -3229,7 +3235,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
"fast_resend_seq_nr:%d "
|
||||
"ssthres:%d "
|
||||
"\n"
|
||||
, this
|
||||
, static_cast<void*>(this)
|
||||
, sample
|
||||
, float(delay / 1000.f)
|
||||
, float(their_delay / 1000.f)
|
||||
|
@ -3335,18 +3341,19 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
|
|||
// When this happens we know that the remote side has
|
||||
// received all of our packets.
|
||||
|
||||
UTP_LOGV("%8p: FIN acked\n", this);
|
||||
UTP_LOGV("%8p: FIN acked\n", static_cast<void*>(this));
|
||||
|
||||
if (!m_attached)
|
||||
{
|
||||
UTP_LOGV("%8p: close initiated here, delete socket\n", this);
|
||||
UTP_LOGV("%8p: close initiated here, delete socket\n"
|
||||
, static_cast<void*>(this));
|
||||
m_error = boost::asio::error::eof;
|
||||
set_state(UTP_STATE_DELETE);
|
||||
test_socket_state();
|
||||
}
|
||||
else
|
||||
{
|
||||
UTP_LOGV("%8p: closing socket\n", this);
|
||||
UTP_LOGV("%8p: closing socket\n", static_cast<void*>(this));
|
||||
m_error = boost::asio::error::eof;
|
||||
set_state(UTP_STATE_ERROR_WAIT);
|
||||
test_socket_state();
|
||||
|
@ -3392,7 +3399,8 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
|
|||
{
|
||||
if (m_slow_start)
|
||||
{
|
||||
UTP_LOGV("%8p: off_target: %d slow_start -> 0\n", this, target_delay - delay);
|
||||
UTP_LOGV("%8p: off_target: %d slow_start -> 0\n"
|
||||
, static_cast<void*>(this), target_delay - delay);
|
||||
m_ssthres = (m_cwnd >> 16) / 2;
|
||||
m_slow_start = false;
|
||||
}
|
||||
|
@ -3424,7 +3432,8 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
|
|||
// aggressive
|
||||
m_slow_start = false;
|
||||
scaled_gain = linear_gain;
|
||||
UTP_LOGV("%8p: cwnd > ssthres (%d) slow_start -> 0\n", this, m_ssthres);
|
||||
UTP_LOGV("%8p: cwnd > ssthres (%d) slow_start -> 0\n"
|
||||
, static_cast<void*>(this), m_ssthres);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3447,7 +3456,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
|
|||
|
||||
UTP_LOGV("%8p: do_ledbat delay:%d off_target: %d window_factor:%f target_factor:%f "
|
||||
"scaled_gain:%f cwnd:%d slow_start:%d\n"
|
||||
, this, delay, target_delay - delay, window_factor / float(1 << 16)
|
||||
, static_cast<void*>(this), delay, target_delay - delay, window_factor / float(1 << 16)
|
||||
, delay_factor / float(1 << 16)
|
||||
, scaled_gain / float(1 << 16), int(m_cwnd >> 16)
|
||||
, int(m_slow_start));
|
||||
|
@ -3469,7 +3478,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
|
|||
if (window_size_left >= m_mtu)
|
||||
{
|
||||
UTP_LOGV("%8p: mtu:%d in_flight:%d adv_wnd:%d cwnd:%d acked_bytes:%d cwnd_full -> 0\n"
|
||||
, this, m_mtu, in_flight, int(m_adv_wnd), int(m_cwnd >> 16), acked_bytes);
|
||||
, static_cast<void*>(this), m_mtu, in_flight, int(m_adv_wnd), int(m_cwnd >> 16), acked_bytes);
|
||||
m_cwnd_full = false;
|
||||
}
|
||||
|
||||
|
@ -3477,7 +3486,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
|
|||
{
|
||||
m_slow_start = false;
|
||||
UTP_LOGV("%8p: cwnd > advertized wnd (%d) slow_start -> 0\n"
|
||||
, this, m_adv_wnd);
|
||||
, static_cast<void*>(this), m_adv_wnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3516,7 +3525,7 @@ void utp_socket_impl::tick(time_point now)
|
|||
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: tick:%s r: %d (%s) w: %d (%s)\n"
|
||||
, this, socket_state_names[m_state], m_read, m_read_handler ? "handler" : "no handler"
|
||||
, static_cast<void*>(this), socket_state_names[m_state], m_read, m_read_handler ? "handler" : "no handler"
|
||||
, m_written, m_write_handler ? "handler" : "no handler");
|
||||
#endif
|
||||
|
||||
|
@ -3579,7 +3588,7 @@ void utp_socket_impl::tick(time_point now)
|
|||
m_timeout = now + milliseconds(packet_timeout());
|
||||
|
||||
UTP_LOGV("%8p: timeout resetting cwnd:%d\n"
|
||||
, this, int(m_cwnd >> 16));
|
||||
, static_cast<void*>(this), int(m_cwnd >> 16));
|
||||
|
||||
// we dropped all packets, that includes the mtu probe
|
||||
m_mtu_seq = 0;
|
||||
|
@ -3594,7 +3603,7 @@ void utp_socket_impl::tick(time_point now)
|
|||
// we're very likely to have an ssthres set, which will make us leave
|
||||
// slow start before inducing more delay or loss.
|
||||
m_slow_start = true;
|
||||
UTP_LOGV("%8p: timeout slow_start -> 1\n", this);
|
||||
UTP_LOGV("%8p: timeout slow_start -> 1\n", static_cast<void*>(this));
|
||||
|
||||
// we need to go one past m_seq_nr to cover the case
|
||||
// where we just sent a SYN packet and then adjusted for
|
||||
|
@ -3609,7 +3618,7 @@ void utp_socket_impl::tick(time_point now)
|
|||
p->need_resend = true;
|
||||
TORRENT_ASSERT(m_bytes_in_flight >= p->size - p->header_size);
|
||||
m_bytes_in_flight -= p->size - p->header_size;
|
||||
UTP_LOGV("%8p: Packet %d lost (timeout).\n", this, i);
|
||||
UTP_LOGV("%8p: Packet %d lost (timeout).\n", static_cast<void*>(this), i);
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(m_bytes_in_flight == 0);
|
||||
|
@ -3624,7 +3633,7 @@ void utp_socket_impl::tick(time_point now)
|
|||
{
|
||||
#if TORRENT_UTP_LOG
|
||||
UTP_LOGV("%8p: %d failed sends in a row. Socket timed out. state:%s\n"
|
||||
, this, p->num_transmissions, socket_state_names[m_state]);
|
||||
, static_cast<void*>(this), p->num_transmissions, socket_state_names[m_state]);
|
||||
#endif
|
||||
|
||||
// the connection is dead
|
||||
|
|
|
@ -268,7 +268,7 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
|
||||
torrent_info const& info = t->torrent_file();
|
||||
peer_request req = r;
|
||||
|
||||
|
||||
std::string request;
|
||||
request.reserve(400);
|
||||
|
||||
|
@ -300,6 +300,8 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
peer_log(peer_log_alert::info, "RESTART_DATA", "data: %d req: (%d, %d) size: %d"
|
||||
, int(m_piece.size()), int(front.piece), int(front.start)
|
||||
, int (front.start + front.length - 1));
|
||||
#else
|
||||
TORRENT_UNUSED(front);
|
||||
#endif
|
||||
|
||||
req.start += m_piece.size();
|
||||
|
|
43
test/Jamfile
43
test/Jamfile
|
@ -69,6 +69,7 @@ lib libtorrent_test
|
|||
<include>../ed25519/src
|
||||
<target-os>windows:<library>advapi32
|
||||
<conditional>@link_libtorrent
|
||||
<toolset>darwin:<cflags>-Wno-unused-command-line-argument
|
||||
|
||||
: # default build
|
||||
<link>shared
|
||||
|
@ -88,6 +89,7 @@ project
|
|||
: requirements
|
||||
<conditional>@link_test
|
||||
<conditional>@link_libtorrent
|
||||
<toolset>darwin:<cflags>-Wno-unused-command-line-argument
|
||||
: default-build
|
||||
<threading>multi
|
||||
<invariant-checks>full
|
||||
|
@ -108,7 +110,6 @@ test-suite libtorrent :
|
|||
test_bloom_filter.cpp
|
||||
test_identify_client.cpp
|
||||
test_merkle.cpp
|
||||
test_alert_manager.cpp
|
||||
test_resolve_links.cpp
|
||||
test_crc32.cpp
|
||||
test_heterogeneous_queue.cpp
|
||||
|
@ -148,6 +149,7 @@ test-suite libtorrent :
|
|||
test_linked_list.cpp
|
||||
test_file_progress.cpp ]
|
||||
|
||||
[ run test_alert_manager.cpp ]
|
||||
[ run test_direct_dht.cpp ]
|
||||
[ run test_magnet.cpp ]
|
||||
[ run test_storage.cpp ]
|
||||
|
@ -212,5 +214,44 @@ alias win-tests :
|
|||
test_checking
|
||||
;
|
||||
|
||||
# the openssl test hangs on the travis osx machine. difficult to debug
|
||||
alias osx-tests :
|
||||
test_primitives
|
||||
test_alert_manager
|
||||
test_direct_dht
|
||||
test_magnet
|
||||
test_storage
|
||||
test_session
|
||||
test_read_piece
|
||||
test_file
|
||||
test_fast_extension
|
||||
test_privacy
|
||||
test_recheck
|
||||
test_resume
|
||||
# test_ssl
|
||||
test_tracker
|
||||
test_checking
|
||||
test_url_seed
|
||||
test_web_seed
|
||||
test_web_seed_redirect
|
||||
test_web_seed_socks4
|
||||
test_web_seed_socks5
|
||||
test_web_seed_socks5_pw
|
||||
test_web_seed_http
|
||||
test_web_seed_http_pw
|
||||
test_web_seed_chunked
|
||||
test_web_seed_ban
|
||||
test_pe_crypto
|
||||
test_remap_files
|
||||
test_utp
|
||||
test_auto_unchoke
|
||||
test_http_connection
|
||||
test_torrent
|
||||
test_transfer
|
||||
test_time_critical
|
||||
test_pex
|
||||
test_priority
|
||||
;
|
||||
|
||||
explicit win-tests ;
|
||||
|
||||
|
|
|
@ -242,6 +242,8 @@ TORRENT_TEST(wait_for_alert)
|
|||
|
||||
time_point end = clock_type::now();
|
||||
TEST_EQUAL(a, static_cast<alert*>(0));
|
||||
fprintf(stderr, "delay: %d ms (expected 1 second)\n"
|
||||
, int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start > milliseconds(900));
|
||||
TEST_CHECK(end - start < milliseconds(1100));
|
||||
|
||||
|
@ -250,6 +252,8 @@ TORRENT_TEST(wait_for_alert)
|
|||
start = clock_type::now();
|
||||
a = mgr.wait_for_alert(seconds(1));
|
||||
end = clock_type::now();
|
||||
|
||||
fprintf(stderr, "delay: %d ms\n", int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start < milliseconds(1));
|
||||
TEST_CHECK(a->type() == torrent_added_alert::alert_type);
|
||||
|
||||
|
@ -262,6 +266,8 @@ TORRENT_TEST(wait_for_alert)
|
|||
|
||||
a = mgr.wait_for_alert(seconds(10));
|
||||
end = clock_type::now();
|
||||
|
||||
fprintf(stderr, "delay: %d ms\n", int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start < milliseconds(500));
|
||||
TEST_CHECK(a->type() == torrent_added_alert::alert_type);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/alert_types.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -63,7 +64,7 @@ struct test_plugin : plugin
|
|||
}
|
||||
};
|
||||
|
||||
dht_direct_response_alert* get_direct_response(session& ses)
|
||||
dht_direct_response_alert* get_direct_response(lt::session& ses)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
|
@ -95,9 +96,9 @@ TORRENT_TEST(direct_dht_request)
|
|||
sp.set_bool(settings_pack::enable_upnp, false);
|
||||
sp.set_int(settings_pack::max_retry_port_bind, 800);
|
||||
sp.set_str(settings_pack::listen_interfaces, "127.0.0.1:42434");
|
||||
session responder(sp, 0);
|
||||
lt::session responder(sp, 0);
|
||||
sp.set_str(settings_pack::listen_interfaces, "127.0.0.1:45434");
|
||||
session requester(sp, 0);
|
||||
lt::session requester(sp, 0);
|
||||
|
||||
responder.add_extension(boost::static_pointer_cast<plugin>(boost::make_shared<test_plugin>()));
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ boost::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
|
|||
sett.set_bool(settings_pack::enable_natpmp, false);
|
||||
sett.set_bool(settings_pack::enable_lsd, false);
|
||||
sett.set_bool(settings_pack::enable_dht, false);
|
||||
ses.reset(new lt::session(sett, session::add_default_plugins));
|
||||
ses.reset(new lt::session(sett, lt::session::add_default_plugins));
|
||||
|
||||
error_code ec;
|
||||
add_torrent_params p;
|
||||
|
|
|
@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "setup_transfer.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
||||
boost::shared_ptr<torrent_info> generate_torrent()
|
||||
{
|
||||
|
@ -52,7 +53,7 @@ boost::shared_ptr<torrent_info> generate_torrent()
|
|||
fs.add_file("test_resume/tmp1", 128 * 1024 * 8);
|
||||
fs.add_file("test_resume/tmp2", 128 * 1024);
|
||||
fs.add_file("test_resume/tmp3", 128 * 1024);
|
||||
libtorrent::create_torrent t(fs, 128 * 1024, 6);
|
||||
lt::create_torrent t(fs, 128 * 1024, 6);
|
||||
|
||||
t.add_tracker("http://torrent_file_tracker.com/announce");
|
||||
|
||||
|
@ -61,7 +62,7 @@ boost::shared_ptr<torrent_info> generate_torrent()
|
|||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
sha1_hash ph;
|
||||
for (int k = 0; k < 20; ++k) ph[k] = libtorrent::random();
|
||||
for (int k = 0; k < 20; ++k) ph[k] = lt::random();
|
||||
t.set_hash(i, ph);
|
||||
}
|
||||
|
||||
|
@ -131,7 +132,7 @@ std::vector<char> generate_resume_data(torrent_info* ti
|
|||
return ret;
|
||||
}
|
||||
|
||||
torrent_handle test_resume_flags(libtorrent::session& ses, int flags
|
||||
torrent_handle test_resume_flags(lt::session& ses, int flags
|
||||
, char const* file_priorities = "1111", char const* resume_file_prio = "")
|
||||
{
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
|
@ -191,7 +192,7 @@ void default_tests(torrent_status const& s)
|
|||
|
||||
TORRENT_TEST(piece_priorities)
|
||||
{
|
||||
session ses;
|
||||
lt::session ses;
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
add_torrent_params p;
|
||||
p.ti = ti;
|
||||
|
@ -237,7 +238,7 @@ TORRENT_TEST(piece_priorities)
|
|||
|
||||
TORRENT_TEST(file_priorities_default)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "", "").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -249,7 +250,7 @@ TORRENT_TEST(file_priorities_default)
|
|||
TORRENT_TEST(file_priorities_resume_seed_mode)
|
||||
{
|
||||
// in share mode file priorities should always be 0
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses,
|
||||
add_torrent_params::flag_share_mode, "", "123").file_priorities();
|
||||
|
||||
|
@ -262,7 +263,7 @@ TORRENT_TEST(file_priorities_resume_seed_mode)
|
|||
TORRENT_TEST(file_priorities_seed_mode)
|
||||
{
|
||||
// in share mode file priorities should always be 0
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses,
|
||||
add_torrent_params::flag_share_mode, "123", "").file_priorities();
|
||||
|
||||
|
@ -276,7 +277,7 @@ TORRENT_TEST(zero_file_prio)
|
|||
{
|
||||
fprintf(stderr, "test_file_prio\n");
|
||||
|
||||
session ses;
|
||||
lt::session ses;
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
add_torrent_params p;
|
||||
p.ti = ti;
|
||||
|
@ -315,7 +316,7 @@ void test_seed_mode(bool file_prio, bool pieces_have, bool piece_prio
|
|||
fprintf(stderr, "test_seed_mode file_prio: %d pieces_have: %d piece_prio: %d\n"
|
||||
, file_prio, pieces_have, piece_prio);
|
||||
|
||||
session ses;
|
||||
lt::session ses;
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
add_torrent_params p;
|
||||
p.ti = ti;
|
||||
|
@ -395,7 +396,7 @@ TORRENT_TEST(seed_mode_preserve)
|
|||
|
||||
TORRENT_TEST(resume_save_load)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_handle h = test_resume_flags(ses, 0, "123", "");
|
||||
|
||||
h.save_resume_data();
|
||||
|
@ -421,7 +422,7 @@ TORRENT_TEST(resume_save_load)
|
|||
|
||||
TORRENT_TEST(resume_save_load_resume)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_handle h = test_resume_flags(ses, 0, "", "123");
|
||||
|
||||
h.save_resume_data();
|
||||
|
@ -450,7 +451,7 @@ TORRENT_TEST(file_priorities_resume_override)
|
|||
// make sure that an empty file_priorities vector in add_torrent_params won't
|
||||
// override the resume data file priorities, even when override resume data
|
||||
// flag is set.
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses,
|
||||
add_torrent_params::flag_override_resume_data, "", "123").file_priorities();
|
||||
|
||||
|
@ -462,7 +463,7 @@ TORRENT_TEST(file_priorities_resume_override)
|
|||
|
||||
TORRENT_TEST(file_priorities_resume)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "", "123").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -473,7 +474,7 @@ TORRENT_TEST(file_priorities_resume)
|
|||
|
||||
TORRENT_TEST(file_priorities1)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "010").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -486,7 +487,7 @@ TORRENT_TEST(file_priorities1)
|
|||
|
||||
TORRENT_TEST(file_priorities2)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "123").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -497,7 +498,7 @@ TORRENT_TEST(file_priorities2)
|
|||
|
||||
TORRENT_TEST(file_priorities3)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "4321").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -508,7 +509,7 @@ TORRENT_TEST(file_priorities3)
|
|||
|
||||
TORRENT_TEST(plain)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
|
||||
torrent_status s = test_resume_flags(ses, 0).status();
|
||||
default_tests(s);
|
||||
|
@ -531,7 +532,7 @@ TORRENT_TEST(plain)
|
|||
|
||||
TORRENT_TEST(use_resume_save_path)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_use_resume_save_path).status();
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -553,7 +554,7 @@ TORRENT_TEST(use_resume_save_path)
|
|||
|
||||
TORRENT_TEST(override_resume_data)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_status s = test_resume_flags(ses
|
||||
, add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_paused).status();
|
||||
|
@ -578,7 +579,7 @@ TORRENT_TEST(override_resume_data)
|
|||
|
||||
TORRENT_TEST(seed_mode)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_seed_mode).status();
|
||||
default_tests(s);
|
||||
|
@ -601,7 +602,7 @@ TORRENT_TEST(seed_mode)
|
|||
|
||||
TORRENT_TEST(upload_mode)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_upload_mode).status();
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -623,7 +624,7 @@ TORRENT_TEST(upload_mode)
|
|||
|
||||
TORRENT_TEST(share_mode)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
torrent_status s = test_resume_flags(ses
|
||||
, add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_share_mode).status();
|
||||
|
@ -647,7 +648,7 @@ TORRENT_TEST(share_mode)
|
|||
|
||||
TORRENT_TEST(auto_managed)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
// resume data overrides the auto-managed flag
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_auto_managed).status();
|
||||
default_tests(s);
|
||||
|
@ -670,7 +671,7 @@ TORRENT_TEST(auto_managed)
|
|||
|
||||
TORRENT_TEST(paused)
|
||||
{
|
||||
libtorrent::session ses;
|
||||
lt::session ses;
|
||||
// resume data overrides the paused flag
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_paused).status();
|
||||
default_tests(s);
|
||||
|
|
Loading…
Reference in New Issue