lt sync 2607 - fixes upnp

This commit is contained in:
Andrew Resch 2008-08-17 00:10:56 +00:00
parent 14a6efef2b
commit 143c1661fe
13 changed files with 61 additions and 8 deletions

View File

@ -268,6 +268,7 @@ private:
if (m_abort) return;
error_code ec;
TORRENT_ASSERT(e.expires_at > time_now());
m_history_timer.expires_at(e.expires_at, ec);
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
}
@ -311,6 +312,7 @@ private:
if (!m_history.empty() && !m_abort)
{
error_code ec;
TORRENT_ASSERT(m_history.back().expires_at > now);
m_history_timer.expires_at(m_history.back().expires_at, ec);
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
}

View File

@ -143,14 +143,22 @@ namespace libtorrent
{
using boost::filesystem::path;
using boost::filesystem::directory_iterator;
#if BOOST_VERSION < 103600
std::string const& leaf = l.leaf();
#else
std::string const& leaf = l.filename();
#endif
if (leaf == ".." || leaf == ".") return;
if (!pred(l)) return;
path f(p / l);
if (is_directory(f))
{
for (directory_iterator i(f), end; i != end; ++i)
#if BOOST_VERSION < 103600
add_files_impl(fs, p, l / i->leaf(), pred);
#else
add_files_impl(fs, p, l / i->filename(), pred);
#endif
}
else
{
@ -162,7 +170,11 @@ namespace libtorrent
template <class Pred>
void add_files(file_storage& fs, boost::filesystem::path const& file, Pred p)
{
#if BOOST_VERSION < 103600
detail::add_files_impl(fs, complete(file).branch_path(), file.leaf(), p);
#else
detail::add_files_impl(fs, complete(file).parent_path(), file.filename(), p);
#endif
}
inline void add_files(file_storage& fs, boost::filesystem::path const& file)

View File

@ -39,8 +39,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/storage.hpp"
#include <boost/thread/thread.hpp>
#include <boost/function.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_array.hpp>

View File

@ -73,7 +73,11 @@ namespace libtorrent
inline boost::system::error_category const& get_system_category()
{ return boost::system::get_system_category(); }
inline boost::system::error_category const& get_posix_category()
#if BOOST_VERSION < 103600
{ return boost::system::get_posix_category(); }
#else
{ return boost::system::get_generic_category(); }
#endif
#endif
}

View File

@ -252,6 +252,7 @@ namespace libtorrent
if (m_supports_dht_port && m_ses.m_dht)
write_dht_port(m_ses.get_dht_settings().service_port);
#endif
if (is_interesting()) write_interested();
}
void bt_peer_connection::write_dht_port(int listen_port)
@ -1435,6 +1436,9 @@ namespace libtorrent
else if (t->num_have() == 0)
{
// don't send a bitfield if we don't have any pieces
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD";
#endif
#ifndef NDEBUG
m_sent_bitfield = true;
#endif

View File

@ -49,7 +49,11 @@ namespace libtorrent
, m_private(false)
{
TORRENT_ASSERT(fs.num_files() > 0);
#if BOOST_VERSION < 103600
if (!m_multifile && m_files.at(0).path.has_branch_path()) m_multifile = true;
#else
if (!m_multifile && m_files.at(0).path.has_parent_path()) m_multifile = true;
#endif
// make sure the size is an even power of 2
#ifndef NDEBUG
@ -75,7 +79,11 @@ namespace libtorrent
, m_private(false)
{
TORRENT_ASSERT(fs.num_files() > 0);
#if BOOST_VERSION < 103600
if (!m_multifile && m_files.at(0).path.has_branch_path()) m_multifile = true;
#else
if (!m_multifile && m_files.at(0).path.has_parent_path()) m_multifile = true;
#endif
const int target_size = 40 * 1024;
int size = fs.total_size() / (target_size / 20);
@ -190,7 +198,11 @@ namespace libtorrent
file_e["length"] = i->size;
entry& path_e = file_e["path"];
#if BOOST_VERSION < 103600
TORRENT_ASSERT(i->path.has_branch_path());
#else
TORRENT_ASSERT(i->path.has_parent_path());
#endif
TORRENT_ASSERT(*i->path.begin() == m_files.name());
for (fs::path::iterator j = boost::next(i->path.begin());

View File

@ -150,10 +150,10 @@ namespace libtorrent { namespace
if_indextoname(*(int*)RTA_DATA(rt_attr), rt_info->name);
break;
case RTA_GATEWAY:
rt_info->gateway = address_v4(*(u_int*)RTA_DATA(rt_attr));
rt_info->gateway = address_v4(ntohl(*(u_int*)RTA_DATA(rt_attr)));
break;
case RTA_DST:
rt_info->destination = address_v4(*(u_int*)RTA_DATA(rt_attr));
rt_info->destination = address_v4(ntohl(*(u_int*)RTA_DATA(rt_attr)));
break;
}
}
@ -230,9 +230,9 @@ namespace libtorrent
bool in_local_network(io_service& ios, address const& addr, error_code& ec)
{
std::vector<ip_interface> const& net = enum_net_interfaces(ios, ec);
std::vector<ip_interface> net = enum_net_interfaces(ios, ec);
if (ec) return false;
for (std::vector<ip_interface>::const_iterator i = net.begin()
for (std::vector<ip_interface>::iterator i = net.begin()
, end(net.end()); i != end; ++i)
{
if (in_subnet(addr, *i)) return true;

View File

@ -131,7 +131,11 @@ namespace libtorrent
void file_storage::add_file(fs::path const& file, size_type size)
{
TORRENT_ASSERT(size >= 0);
#if BOOST_VERSION < 103600
if (!file.has_branch_path())
#else
if (!file.has_parent_path())
#endif
{
// you have already added at least one file with a
// path to the file (branch_path), which means that

View File

@ -88,10 +88,10 @@ namespace libtorrent
lazy_entry* top = stack.back();
if (int(stack.size()) > depth_limit) return fail_bdecode();
if (start == end) return fail_bdecode();
if (start >= end) return fail_bdecode();
char t = *start;
++start;
if (start == end && t != 'e') return fail_bdecode();
if (start >= end && t != 'e') return fail_bdecode();
switch (top->type())
{
@ -107,8 +107,10 @@ namespace libtorrent
start = parse_int(start, end, ':', len);
if (start == 0 || start + len + 3 > end || *start != ':') return fail_bdecode();
++start;
if (start == end) fail_bdecode();
lazy_entry* ent = top->dict_append(start);
start += len;
if (start >= end) fail_bdecode();
stack.push_back(ent);
t = *start;
++start;

View File

@ -2133,6 +2133,8 @@ namespace libtorrent
{
if (m_interesting) return;
m_interesting = true;
boost::shared_ptr<torrent> t = m_torrent.lock();
if (!t->valid_metadata()) return;
write_interested();
#ifdef TORRENT_VERBOSE_LOGGING
@ -2144,6 +2146,8 @@ namespace libtorrent
{
if (!m_interesting) return;
m_interesting = false;
boost::shared_ptr<torrent> t = m_torrent.lock();
if (!t->valid_metadata()) return;
write_not_interested();
m_became_uninteresting = time_now();

View File

@ -265,7 +265,11 @@ namespace libtorrent
create_directory(new_path);
for (basic_directory_iterator<Path> i(old_path), end; i != end; ++i)
{
#if BOOST_VERSION < 103600
recursive_copy(i->path(), new_path / i->leaf(), ec);
#else
recursive_copy(i->path(), new_path / i->filename(), ec);
#endif
if (ec) return;
}
}

View File

@ -385,7 +385,11 @@ namespace libtorrent
{
name = tmp.leaf();
}
#if BOOST_VERSION < 103600
else if (tmp.has_branch_path())
#else
else if (tmp.has_parent_path())
#endif
{
fs::path p;
for (fs::path::iterator i = tmp.begin()

View File

@ -339,7 +339,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
{
m_log << time_now_string() << " <== (" << from << ") UPnP device "
"ignored because it's not on our local network ";
std::vector<ip_interface> const& net = enum_net_interfaces(m_io_service, ec);
std::vector<ip_interface> net = enum_net_interfaces(m_io_service, ec);
for (std::vector<ip_interface>::const_iterator i = net.begin()
, end(net.end()); i != end; ++i)
{