fix build issue out of recent changes of exported functions

This commit is contained in:
Arvid Norberg 2015-03-16 04:38:28 +00:00
parent bbcfeeab8d
commit 1b07ec491d
9 changed files with 115 additions and 51 deletions

View File

@ -114,6 +114,7 @@ set(kademlia_sources
dos_blocker
dht_tracker
node
node_entry
refresh
rpc_manager
find_data

View File

@ -631,6 +631,7 @@ SOURCES =
KADEMLIA_SOURCES =
dht_tracker
node
node_entry
refresh
rpc_manager
find_data

View File

@ -40,6 +40,17 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace libtorrent;
namespace lt = libtorrent;
void sleep_ms(int milliseconds)
{
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
Sleep(milliseconds);
#elif defined TORRENT_BEOS
snooze_until(system_time() + boost::int64_t(milliseconds) * 1000, B_SYSTEM_TIMEBASE);
#else
usleep(milliseconds * 1000);
#endif
}
int load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000)
{
ec.clear();
@ -210,7 +221,7 @@ int main(int argc, char* argv[])
fprintf(stderr, "fetching feed ... %c", spinner[i]);
while (fs.updating)
{
sleep(100);
sleep_ms(100);
i = (i + 1) % 4;
fprintf(stderr, "\b%c", spinner[i]);
fs = fh.get_feed_status();
@ -251,7 +262,7 @@ int main(int argc, char* argv[])
, st.num_peers, st.num_seeds, status.c_str());
}
sleep(500);
sleep_ms(500);
if (quit) break;
printf("\033[%dA", int(t.size()));
}

View File

@ -56,10 +56,10 @@ namespace libtorrent
{
// return true if the status code is 200, 206, or in the 300-400 range
bool is_ok_status(int http_status);
TORRENT_EXTRA_EXPORT bool is_ok_status(int http_status);
// return true if the status code is a redirect
bool is_redirect(int http_status);
TORRENT_EXTRA_EXPORT bool is_redirect(int http_status);
TORRENT_EXTRA_EXPORT std::string resolve_redirect_location(std::string referrer
, std::string location);

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/union_endpoint.hpp"
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
#include "libtorrent/time.hpp" // for time_point
namespace libtorrent { namespace dht
{
@ -45,43 +45,10 @@ namespace libtorrent { namespace dht
struct node_entry
{
node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = 0xffff
, bool pinged = false)
: last_queried(pinged ? aux::time_now() : min_time())
, id(id_)
, a(ep.address().to_v4().to_bytes())
, p(ep.port())
, rtt(roundtriptime & 0xffff)
, timeout_count(pinged ? 0 : 0xff)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = aux::time_now();
#endif
}
node_entry(udp::endpoint ep)
: last_queried(min_time())
, id(0)
, a(ep.address().to_v4().to_bytes())
, p(ep.port())
, rtt(0xffff)
, timeout_count(0xff)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = aux::time_now();
#endif
}
node_entry()
: last_queried(min_time())
, id(0)
, p(0)
, rtt(0xffff)
, timeout_count(0xff)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = aux::time_now();
#endif
}
, bool pinged = false);
node_entry(udp::endpoint ep);
node_entry();
void update_rtt(int new_rtt);
bool pinged() const { return timeout_count != 0xff; }
void set_pinged() { if (timeout_count == 0xff) timeout_count = 0; }
@ -90,14 +57,6 @@ struct node_entry
void reset_fail_count() { if (pinged()) timeout_count = 0; }
udp::endpoint ep() const { return udp::endpoint(address_v4(a), p); }
bool confirmed() const { return timeout_count == 0; }
void update_rtt(int new_rtt)
{
TORRENT_ASSERT(new_rtt <= 0xffff);
TORRENT_ASSERT(new_rtt >= 0);
if (new_rtt == 0xffff) return;
if (rtt == 0xffff) rtt = new_rtt;
else rtt = int(rtt) * 2 / 3 + int(new_rtt) / 3;
}
address addr() const { return address_v4(a); }
int port() const { return p; }

View File

@ -7,6 +7,7 @@ KADEMLIA_SOURCES = \
kademlia/dht_tracker.cpp \
kademlia/find_data.cpp \
kademlia/node.cpp \
kademlia/node_entry.cpp \
kademlia/node_id.cpp \
kademlia/refresh.cpp \
kademlia/routing_table.cpp \

View File

@ -0,0 +1,90 @@
/*
Copyright (c) 2006-2014, 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.
*/
#include "libtorrent/kademlia/node_entry.hpp"
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
namespace libtorrent { namespace dht
{
node_entry::node_entry(node_id const& id_, udp::endpoint ep
, int roundtriptime
, bool pinged)
: last_queried(pinged ? aux::time_now() : min_time())
, id(id_)
, a(ep.address().to_v4().to_bytes())
, p(ep.port())
, rtt(roundtriptime & 0xffff)
, timeout_count(pinged ? 0 : 0xff)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = aux::time_now();
#endif
}
node_entry::node_entry(udp::endpoint ep)
: last_queried(min_time())
, id(0)
, a(ep.address().to_v4().to_bytes())
, p(ep.port())
, rtt(0xffff)
, timeout_count(0xff)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = aux::time_now();
#endif
}
node_entry::node_entry()
: last_queried(min_time())
, id(0)
, p(0)
, rtt(0xffff)
, timeout_count(0xff)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = aux::time_now();
#endif
}
void node_entry::update_rtt(int new_rtt)
{
TORRENT_ASSERT(new_rtt <= 0xffff);
TORRENT_ASSERT(new_rtt >= 0);
if (new_rtt == 0xffff) return;
if (rtt == 0xffff) rtt = new_rtt;
else rtt = int(rtt) * 2 / 3 + int(new_rtt) / 3;
}
}}

View File

@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/hasher.hpp>
#include <libtorrent/session_settings.hpp> // for dht_settings
#include <libtorrent/time.hpp>
#include <libtorrent/aux_/time.hpp> // for aux::time_now
#ifdef TORRENT_DHT_VERBOSE_LOGGING
#include <fstream>

View File

@ -284,7 +284,7 @@ void test_transfer(settings_pack const& sett)
}
TEST_CHECK(resume_data.size());
fprintf(stderr, "%s\n", resume_data.data());
fprintf(stderr, "%s\n", &resume_data[0]);
ses2.remove_torrent(tor2);