disable warning for unused command line argument and fix warnings. remove redundant travis build config. use new preprocessor on clang to avoid warnings

This commit is contained in:
arvidn 2015-09-02 01:30:40 -04:00
parent b45c585a78
commit 17c5759829
50 changed files with 347 additions and 192 deletions

View File

@ -6,10 +6,9 @@ os:
env:
- variant=test_debug lang=cpp11 sim=1
# - variant=test_debug lang=cpp11 sim=0
# - variant=test_debug lang=cpp98 sim=0
# - variant=test_release lang=cpp11 sim=0
# - variant=test_barebones lang=cpp11 sim=0
- variant=test_debug lang=cpp98 sim=0
- variant=test_release lang=cpp11 sim=0
- variant=test_barebones lang=cpp11 sim=0
git:
submodules: false
@ -43,11 +42,12 @@ before_install:
- if [ $TRAVIS_OS_NAME == "osx" ]; then brew install --quiet ccache boost-build boost-python; fi
- if [ $TRAVIS_OS_NAME == "osx" ]; then export toolset="darwin-${lang}"; fi
- if [ $TRAVIS_OS_NAME == "linux" ]; then export toolset="gcc-${lang}"; fi
- 'echo "using toolset: " ${toolset}'
install:
- 'echo "using toolset: " ${toolset}'
- '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'
# 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
@ -64,9 +64,9 @@ script:
- cd ../bindings/python
- bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset stage_module
- LD_LIBRARY_PATH=. DYLD_LIBRARY_PATH=. python test.py
- if [ $sim ]; then
- if [ $sim = "1" ]; then
cd ../../simulation;
bjam --hash -j3 crypto=built-in $toolset;
bjam --hash -j2 crypto=built-in $toolset;
fi
- ccache --show-stats

13
Jamfile
View File

@ -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)
@ -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 ;

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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(&lt::session::is_paused))
.def("id", allow_threads(&lt::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(&lt::session::add_port_mapping))
.def("delete_port_mapping", allow_threads(&lt::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")

View File

@ -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();

View File

@ -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
;

View File

@ -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 \

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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;
}

View File

@ -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

View File

@ -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*

View File

@ -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");
@ -1270,16 +1279,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: %"
PRIx64 "\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;
@ -1317,11 +1325,11 @@ 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;
@ -1329,8 +1337,7 @@ bool block_cache::inc_block_refcount(cached_piece_entry* pe, int block, int reas
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: %"
PRIx64 "\n"
"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);
@ -1389,7 +1396,7 @@ 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;
@ -1397,8 +1404,7 @@ void block_cache::dec_block_refcount(cached_piece_entry* pe, int block, int reas
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: %"
PRIx64 "\n"
"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;

View File

@ -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)

View File

@ -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 ------

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -175,7 +175,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 +193,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;

View File

@ -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

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -67,6 +67,7 @@ const rlim_t rlim_infinity = RLIM_INFINITY;
#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 +290,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 +333,7 @@ namespace aux {
return SSL_TLSEXT_ERR_OK;
}
} // anonymous namesoace
#endif
session_impl::session_impl(io_service& ios)
@ -456,8 +459,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 +1930,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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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();

View File

@ -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

View File

@ -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>()));

View File

@ -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;

View File

@ -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);