parent
3c785b96fc
commit
c557432431
107
.travis.yml
107
.travis.yml
|
@ -5,9 +5,10 @@ os:
|
|||
- osx
|
||||
|
||||
env:
|
||||
- variant=test_release sim=0 coverage=1 docs=1
|
||||
- variant=test_debug sim=1 coverage=0
|
||||
- variant=test_barebones sim=0 coverage=0
|
||||
- variant=test_release coverage=1 docs=1
|
||||
- variant=test_debug sim=1
|
||||
- variant=test_barebones
|
||||
- analyze=1
|
||||
|
||||
git:
|
||||
submodules: false
|
||||
|
@ -36,11 +37,13 @@ addons:
|
|||
- libboost1.55-tools-dev
|
||||
- python2.7-dev
|
||||
- g++-4.8
|
||||
- cppcheck
|
||||
|
||||
before_install:
|
||||
|
||||
- git submodule update --init --recursive
|
||||
- if [ $TRAVIS_OS_NAME == "osx" ]; then brew update > /dev/null && brew install --quiet ccache boost-build boost-python; fi
|
||||
- 'if [[ $TRAVIS_OS_NAME == "osx" && $docs = "1" ]]; then
|
||||
- 'if [[ $TRAVIS_OS_NAME == "osx" && "$variant" != "" ]]; then brew update > /dev/null && brew install --quiet ccache boost-build boost-python; fi'
|
||||
- 'if [[ $TRAVIS_OS_NAME == "osx" && "$docs" = "1" ]]; then
|
||||
brew install --quiet https://raw.githubusercontent.com/catap/homebrew/docutils/Library/Formula/docutils.rb;
|
||||
mkdir -p /Users/travis/Library/Python/2.7/lib/python/site-packages;
|
||||
echo ''import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")'' >> /Users/travis/Library/Python/2.7/lib/python/site-packages/homebrew.pth;
|
||||
|
@ -54,7 +57,7 @@ before_install:
|
|||
- if [ $TRAVIS_OS_NAME == "osx" ]; then export toolset="darwin"; export sim="0"; fi
|
||||
- if [ $TRAVIS_OS_NAME == "osx" ]; then export target="osx-tests"; fi
|
||||
- if [ $TRAVIS_OS_NAME == "linux" ]; then export toolset="gcc"; fi
|
||||
- if [[ $TRAVIS_OS_NAME == "linux" && $coverage == "1" ]]; then
|
||||
- if [[ $TRAVIS_OS_NAME == "linux" && "$coverage" == "1" ]]; then
|
||||
export coverage_toolset=gcc-coverage;
|
||||
pip install --user codecov;
|
||||
else
|
||||
|
@ -63,6 +66,7 @@ before_install:
|
|||
- 'echo "using toolset: " ${toolset}'
|
||||
|
||||
install:
|
||||
|
||||
- g++-4.8 --version
|
||||
- 'echo "using gcc : : ccache g++-4.8 : <cflags>-std=c11 <cxxflags>-std=c++11 ;" > ~/user-config.jam'
|
||||
- 'echo "using gcc : coverage : ccache g++-4.8 : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>--coverage <linkflags>--coverage ;" >> ~/user-config.jam'
|
||||
|
@ -72,41 +76,76 @@ install:
|
|||
# we're building with -Werror, we can't have those warnings
|
||||
- 'echo "using darwin : : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>-Wno-deprecated-declarations ;" >> ~/user-config.jam'
|
||||
- 'echo "using python : 2.7 ;" >> ~/user-config.jam'
|
||||
- ccache -V && ccache --show-stats && ccache --zero-stats
|
||||
- if [[ $docs == "1" && $TRAVIS_OS_NAME == "osx" ]]; then rst2html.py --version; fi
|
||||
- 'if [[ "$variant" != "" ]]; then ccache -V && ccache --show-stats && ccache --zero-stats; fi'
|
||||
- if [[ "$docs" == "1" && $TRAVIS_OS_NAME == "osx" ]]; then rst2html.py --version; fi
|
||||
|
||||
script:
|
||||
# disable invoking docutils for now, until we can have a modern version of it
|
||||
- cd docs
|
||||
- if [[ $docs == "1" && $TRAVIS_OS_NAME == "osx" ]]; then make RST2HTML=rst2html.py; fi
|
||||
- cd ..
|
||||
|
||||
- cd test
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant -l900 $coverage_toolset $target
|
||||
# if we're building with code coverage, report it as soon as possible
|
||||
- if [[ $TRAVIS_OS_NAME == "linux" && $coverage == "1" ]]; then
|
||||
codecov --root .. --gcov-exec gcov-4.8;
|
||||
fi
|
||||
- 'if [[ "$docs" == "1" && $TRAVIS_OS_NAME == "osx" ]]; then
|
||||
cd docs;
|
||||
make RST2HTML=rst2html.py;
|
||||
cd ..;
|
||||
fi'
|
||||
|
||||
- cd ../examples
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset link=shared bt-get bt-get2;
|
||||
- cd ..
|
||||
# if variant is not set, we do not want to build anything
|
||||
# if we are building with code coverage, report it as soon as possible
|
||||
- 'if [ "$variant" != "" ]; then
|
||||
cd test;
|
||||
bjam --hash -j3 warnings-as-errors=on variant=$variant -l900 $coverage_toolset $target;
|
||||
if [[ $TRAVIS_OS_NAME == "linux" && "$coverage" == "1" ]]; then
|
||||
codecov --root .. --gcov-exec gcov-4.8;
|
||||
fi;
|
||||
cd ../examples;
|
||||
bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset link=shared bt-get bt-get2;
|
||||
cd ..;
|
||||
fi'
|
||||
|
||||
# build libtorrent separately and install it in a temporary (well known) dir
|
||||
# we have to do this because on linux the name of the python module is the same
|
||||
# as the main library, so we can't stage them to the same directory
|
||||
- bjam --hash -j3 warnings-as-errors=on link=shared variant=$variant $toolset install location=./lib
|
||||
|
||||
- cd bindings/python
|
||||
# as the main library, so we cannot stage them to the same directory
|
||||
# here we specify the temporary lib dir as a path to look for the main library
|
||||
- bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset stage_module libtorrent-link=shared install-type=LIB dll-path=../../lib
|
||||
- LD_LIBRARY_PATH=../../lib DYLD_LIBRARY_PATH=../../lib python test.py
|
||||
- cd ../..
|
||||
- 'if [ "$variant" != "" ]; then
|
||||
bjam --hash -j3 warnings-as-errors=on link=shared variant=$variant $toolset install location=./lib;
|
||||
cd bindings/python;
|
||||
bjam --hash -j3 warnings-as-errors=on variant=$variant $toolset stage_module libtorrent-link=shared install-type=LIB dll-path=../../lib;
|
||||
LD_LIBRARY_PATH=../../lib DYLD_LIBRARY_PATH=../../lib python test.py;
|
||||
cd ../..;
|
||||
fi'
|
||||
|
||||
- cd simulation
|
||||
- if [ $sim = "1" ]; then
|
||||
bjam --hash -j2 crypto=built-in warnings-as-errors=on $coverage_toolset;
|
||||
fi
|
||||
- cd ..
|
||||
- ccache --show-stats
|
||||
# simulation
|
||||
- 'if [ "$variant" != "" ]; then
|
||||
cd simulation;
|
||||
if [ "$sim" == "1" ]; then
|
||||
bjam --hash -j2 crypto=built-in warnings-as-errors=on $coverage_toolset;
|
||||
fi;
|
||||
cd ..;
|
||||
fi'
|
||||
|
||||
# run cppcheck if enabled
|
||||
- 'if [[ "$analyze" == "1" ]]; then
|
||||
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
|
||||
cppcheck --version;
|
||||
find src -type f | grep ".*\.cpp$" >cppcheck.files;
|
||||
cppcheck -DTORRENT_USE_IPV6="1" -DTORRENT_USE_I2P="1"
|
||||
-DTORRENT_USE_OPENSSL="1" -DTORRENT_USE_INVARIANT_CHECKS="1"
|
||||
-DTORRENT_EXPENSIVE_INVARIANT_CHECKS="1" -DTORRENT_USE_ASSERTS="1"
|
||||
-UTORRENT_DISABLE_MUTABLE_TORRENTS -UTORRENT_DISABLE_LOGGING
|
||||
-UTORRENT_DEBUG_BUFFERS -UTORRENT_EXPORT_EXTRA
|
||||
--suppress=preprocessorErrorDirective
|
||||
--suppress=syntaxError
|
||||
--template "{file}({line}): {severity} ({id}): {message}"
|
||||
--inline-suppr --force --std=c++11 -j2 -I include -I /usr/local/include
|
||||
--file-list=cppcheck.files 2> cppcheck.txt;
|
||||
if [ -s cppcheck.txt ]; then
|
||||
echo " ======= CPPCHECK ERRORS =====";
|
||||
cat cppcheck.txt;
|
||||
exit 1;
|
||||
fi;
|
||||
fi;
|
||||
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
|
||||
echo "nothing here yet";
|
||||
fi;
|
||||
fi'
|
||||
|
||||
- 'if [[ "$variant" != "" ]]; then ccache --show-stats; fi'
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_PACKET_BUFFER_HPP_INCLUDED
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "boost/cstdint.hpp"
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace libtorrent
|
||||
|
|
|
@ -1031,6 +1031,7 @@ namespace libtorrent
|
|||
// skip the file we just put in place, so we put the pad
|
||||
// file after it
|
||||
++i;
|
||||
if (i == m_files.end()) break;
|
||||
|
||||
// tail-padding is enabled, and the offset after this file is not
|
||||
// aligned and it's not the last file. The last file must be padded
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace
|
|||
fingerprint ret("..", 0, 0, 0, 0);
|
||||
ret.name[1] = 0;
|
||||
ret.tag_version = 0;
|
||||
if (sscanf(ids, "%c%d-%d-%d--", &ret.name[0], &ret.major_version, &ret.minor_version
|
||||
if (sscanf(ids, "%c%3d-%3d-%3d--", &ret.name[0], &ret.major_version, &ret.minor_version
|
||||
, &ret.revision_version) != 4
|
||||
|| !is_print(ret.name[0]))
|
||||
return boost::optional<fingerprint>();
|
||||
|
|
|
@ -228,7 +228,7 @@ namespace
|
|||
bloom_filter<256> seeds;
|
||||
|
||||
for (std::set<peer_entry>::const_iterator peer_it = v.peers.begin()
|
||||
, end(v.peers.end()); peer_it != end; ++peer_it)
|
||||
, end(v.peers.end()); peer_it != end; ++peer_it)
|
||||
{
|
||||
sha1_hash iphash;
|
||||
hash_address(peer_it->addr.address(), iphash);
|
||||
|
|
|
@ -651,41 +651,6 @@ namespace libtorrent
|
|||
if (p.index == piece_pos::we_have_index)
|
||||
++num_have;
|
||||
|
||||
#if 0
|
||||
if (t != 0)
|
||||
{
|
||||
int actual_peer_count = 0;
|
||||
for (torrent::const_peer_iterator peer = t->begin();
|
||||
peer != t->end(); ++peer)
|
||||
{
|
||||
if (peer->second->has_piece(index)) actual_peer_count++;
|
||||
}
|
||||
|
||||
TORRENT_ASSERT((int)i->peer_count == actual_peer_count);
|
||||
/*
|
||||
int num_downloaders = 0;
|
||||
for (std::vector<peer_connection*>::const_iterator peer = t->begin();
|
||||
peer != t->end();
|
||||
++peer)
|
||||
{
|
||||
const std::vector<piece_block>& queue = (*peer)->download_queue();
|
||||
if (std::find_if(queue.begin(), queue.end(), has_index(index)) == queue.end()) continue;
|
||||
|
||||
++num_downloaders;
|
||||
}
|
||||
|
||||
if (i->downloading())
|
||||
{
|
||||
TORRENT_ASSERT(num_downloaders == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
TORRENT_ASSERT(num_downloaders == 0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p.index == piece_pos::we_have_index)
|
||||
{
|
||||
TORRENT_ASSERT(t == 0 || t->have_piece(index));
|
||||
|
@ -730,22 +695,22 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
int count_downloading = std::count_if(
|
||||
int const count_downloading = std::count_if(
|
||||
m_downloads[piece_pos::piece_downloading].begin()
|
||||
, m_downloads[piece_pos::piece_downloading].end()
|
||||
, has_index(index));
|
||||
|
||||
int count_full = std::count_if(
|
||||
int const count_full = std::count_if(
|
||||
m_downloads[piece_pos::piece_full].begin()
|
||||
, m_downloads[piece_pos::piece_full].end()
|
||||
, has_index(index));
|
||||
|
||||
int count_finished = std::count_if(
|
||||
int const count_finished = std::count_if(
|
||||
m_downloads[piece_pos::piece_finished].begin()
|
||||
, m_downloads[piece_pos::piece_finished].end()
|
||||
, has_index(index));
|
||||
|
||||
int count_zero = std::count_if(
|
||||
int const count_zero = std::count_if(
|
||||
m_downloads[piece_pos::piece_zero_prio].begin()
|
||||
, m_downloads[piece_pos::piece_zero_prio].end()
|
||||
, has_index(index));
|
||||
|
|
|
@ -5997,10 +5997,10 @@ namespace aux {
|
|||
if (f != NULL)
|
||||
{
|
||||
time_point m = min_time();
|
||||
if (_wakeups.size() > 0) m = _wakeups[0].timestamp;
|
||||
if (!_wakeups.empty()) m = _wakeups[0].timestamp;
|
||||
time_point prev = m;
|
||||
boost::uint64_t prev_csw = 0;
|
||||
if (_wakeups.size() > 0) prev_csw = _wakeups[0].context_switches;
|
||||
if (!_wakeups.empty()) prev_csw = _wakeups[0].context_switches;
|
||||
fprintf(f, "abs. time\trel. time\tctx switch\tidle-wakeup\toperation\n");
|
||||
for (int i = 0; i < _wakeups.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -856,7 +856,7 @@ namespace libtorrent
|
|||
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
if (tmp.size() == 0 || bdecode(&tmp[0], &tmp[0] + tmp.size(), e, ec) != 0)
|
||||
if (tmp.empty() || bdecode(&tmp[0], &tmp[0] + tmp.size(), e, ec) != 0)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw invalid_torrent_file(ec);
|
||||
|
@ -926,7 +926,7 @@ namespace libtorrent
|
|||
if (ret < 0) throw invalid_torrent_file(ec);
|
||||
|
||||
bdecode_node e;
|
||||
if (buf.size() == 0 || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
if (buf.empty() || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
throw invalid_torrent_file(ec);
|
||||
|
||||
if (!parse_torrent_file(e, ec, flags))
|
||||
|
@ -954,7 +954,7 @@ namespace libtorrent
|
|||
if (ret < 0) throw invalid_torrent_file(ec);
|
||||
|
||||
bdecode_node e;
|
||||
if (buf.size() == 0 || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
if (buf.empty() || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
throw invalid_torrent_file(ec);
|
||||
|
||||
if (!parse_torrent_file(e, ec, flags))
|
||||
|
@ -1019,7 +1019,7 @@ namespace libtorrent
|
|||
if (ret < 0) return;
|
||||
|
||||
bdecode_node e;
|
||||
if (buf.size() == 0 || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
if (buf.empty() || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
return;
|
||||
parse_torrent_file(e, ec, flags);
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ namespace libtorrent
|
|||
if (ret < 0) return;
|
||||
|
||||
bdecode_node e;
|
||||
if (buf.size() == 0 || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
if (buf.empty() || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
return;
|
||||
parse_torrent_file(e, ec, flags);
|
||||
|
||||
|
|
|
@ -79,7 +79,9 @@ struct socks5 : boost::enable_shared_from_this<socks5>
|
|||
, m_timer(ios)
|
||||
, m_abort(false)
|
||||
, m_active(false)
|
||||
{}
|
||||
{
|
||||
memset(m_tmp_buf, 0, sizeof(m_tmp_buf));
|
||||
}
|
||||
|
||||
void start(aux::proxy_settings const& ps);
|
||||
void close();
|
||||
|
|
|
@ -302,14 +302,14 @@ namespace libtorrent { namespace
|
|||
return true;
|
||||
}
|
||||
|
||||
const int num_pex_timers = sizeof(m_last_pex)/sizeof(m_last_pex[0]);
|
||||
int const num_pex_timers = sizeof(m_last_pex)/sizeof(m_last_pex[0]);
|
||||
for (int i = 0; i < num_pex_timers-1; ++i)
|
||||
m_last_pex[i] = m_last_pex[i+1];
|
||||
m_last_pex[num_pex_timers-1] = now;
|
||||
|
||||
bdecode_node pex_msg;
|
||||
error_code ec;
|
||||
int ret = bdecode(body.begin, body.end, pex_msg, ec);
|
||||
int const ret = bdecode(body.begin, body.end, pex_msg, ec);
|
||||
if (ret != 0 || pex_msg.type() != bdecode_node::dict_t)
|
||||
{
|
||||
m_pc.disconnect(errors::invalid_pex_message, op_bittorrent, 2);
|
||||
|
@ -325,7 +325,7 @@ namespace libtorrent { namespace
|
|||
#endif
|
||||
if (p)
|
||||
{
|
||||
int num_peers = p.string_length() / 6;
|
||||
int const num_peers = p.string_length() / 6;
|
||||
char const* in = p.string_ptr();
|
||||
|
||||
for (int i = 0; i < num_peers; ++i)
|
||||
|
@ -345,14 +345,14 @@ namespace libtorrent { namespace
|
|||
#endif
|
||||
if (p && pf && pf.string_length() == p.string_length() / 6)
|
||||
{
|
||||
int num_peers = pf.string_length();
|
||||
int const num_peers = pf.string_length();
|
||||
char const* in = p.string_ptr();
|
||||
char const* fin = pf.string_ptr();
|
||||
|
||||
for (int i = 0; i < num_peers; ++i)
|
||||
{
|
||||
tcp::endpoint adr = detail::read_v4_endpoint<tcp::endpoint>(in);
|
||||
char flags = *fin++;
|
||||
char const flags = *fin++;
|
||||
|
||||
if (int(m_peers.size()) >= m_torrent.settings().get_int(settings_pack::max_pex_peers))
|
||||
break;
|
||||
|
@ -377,7 +377,7 @@ namespace libtorrent { namespace
|
|||
#endif
|
||||
if (p6 != 0 && p6.type() == bdecode_node::string_t)
|
||||
{
|
||||
int num_peers = p6.string_length() / 18;
|
||||
int const num_peers = p6.string_length() / 18;
|
||||
char const* in = p6.string_ptr();
|
||||
|
||||
for (int i = 0; i < num_peers; ++i)
|
||||
|
@ -400,14 +400,14 @@ namespace libtorrent { namespace
|
|||
&& p6f.type() == bdecode_node::string_t
|
||||
&& p6f.string_length() == p6.string_length() / 18)
|
||||
{
|
||||
int num_peers = p6f.string_length();
|
||||
int const num_peers = p6f.string_length();
|
||||
char const* in = p6.string_ptr();
|
||||
char const* fin = p6f.string_ptr();
|
||||
|
||||
for (int i = 0; i < num_peers; ++i)
|
||||
{
|
||||
tcp::endpoint adr = detail::read_v6_endpoint<tcp::endpoint>(in);
|
||||
char flags = *fin++;
|
||||
char const flags = *fin++;
|
||||
// ignore local addresses unless the peer is local to us
|
||||
if (is_local(adr.address()) && !is_local(m_pc.remote().address())) continue;
|
||||
if (int(m_peers6.size()) >= m_torrent.settings().get_int(settings_pack::max_pex_peers))
|
||||
|
@ -419,7 +419,7 @@ namespace libtorrent { namespace
|
|||
if (j != m_peers6.end() && *j == v) continue;
|
||||
m_peers6.insert(j, v);
|
||||
m_torrent.add_peer(adr, peer_info::pex, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
|
@ -438,7 +438,7 @@ namespace libtorrent { namespace
|
|||
// no handshake yet
|
||||
if (!m_message_index) return;
|
||||
|
||||
time_point now = aux::time_now();
|
||||
time_point const now = aux::time_now();
|
||||
if (now - seconds(60) < m_last_msg)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
|
@ -449,7 +449,7 @@ namespace libtorrent { namespace
|
|||
}
|
||||
static time_point global_last = min_time();
|
||||
|
||||
int num_peers = m_torrent.num_peers();
|
||||
int const num_peers = m_torrent.num_peers();
|
||||
if (num_peers <= 1) return;
|
||||
|
||||
// don't send pex messages more often than 1 every 100 ms, and
|
||||
|
|
|
@ -2111,7 +2111,7 @@ bool utp_socket_impl::send_pkt(int flags)
|
|||
}
|
||||
else if (ec)
|
||||
{
|
||||
TORRENT_ASSERT(stack_alloced != (payload_size != 0));
|
||||
TORRENT_ASSERT(stack_alloced != bool(payload_size != 0));
|
||||
m_error = ec;
|
||||
set_state(UTP_STATE_ERROR_WAIT);
|
||||
test_socket_state();
|
||||
|
|
Loading…
Reference in New Issue