lt sync
This commit is contained in:
parent
77d4fefba9
commit
431664fec4
|
@ -102,7 +102,9 @@ namespace libtorrent
|
|||
int disk_allocations() const
|
||||
{ return m_allocations; }
|
||||
#endif
|
||||
|
||||
|
||||
void join();
|
||||
|
||||
// aborts read operations
|
||||
void stop(boost::intrusive_ptr<piece_manager> s);
|
||||
void add_job(disk_io_job const& j
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace detail
|
|||
template<class Addr>
|
||||
Addr zero()
|
||||
{
|
||||
typename Addr::bytes_type zero;
|
||||
Addr zero;
|
||||
std::fill(zero.begin(), zero.end(), 0);
|
||||
return Addr(zero);
|
||||
return zero;
|
||||
}
|
||||
|
||||
template<>
|
||||
|
@ -87,8 +87,8 @@ namespace detail
|
|||
template<class Addr>
|
||||
Addr plus_one(Addr const& a)
|
||||
{
|
||||
typename Addr::bytes_type tmp(a.to_bytes());
|
||||
typedef typename Addr::bytes_type::reverse_iterator iter;
|
||||
Addr tmp(a);
|
||||
typedef typename Addr::reverse_iterator iter;
|
||||
for (iter i = tmp.rbegin()
|
||||
, end(tmp.rend()); i != end; ++i)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ namespace detail
|
|||
}
|
||||
*i = 0;
|
||||
}
|
||||
return Addr(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline boost::uint16_t plus_one(boost::uint16_t val) { return val + 1; }
|
||||
|
@ -107,8 +107,8 @@ namespace detail
|
|||
template<class Addr>
|
||||
Addr minus_one(Addr const& a)
|
||||
{
|
||||
typename Addr::bytes_type tmp(a.to_bytes());
|
||||
typedef typename Addr::bytes_type::reverse_iterator iter;
|
||||
Addr tmp(a);
|
||||
typedef typename Addr::reverse_iterator iter;
|
||||
for (iter i = tmp.rbegin()
|
||||
, end(tmp.rend()); i != end; ++i)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ namespace detail
|
|||
}
|
||||
*i = (std::numeric_limits<typename iter::value_type>::max)();
|
||||
}
|
||||
return Addr(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline boost::uint16_t minus_one(boost::uint16_t val) { return val - 1; }
|
||||
|
@ -127,9 +127,9 @@ namespace detail
|
|||
template<class Addr>
|
||||
Addr max_addr()
|
||||
{
|
||||
typename Addr::bytes_type tmp;
|
||||
Addr tmp;
|
||||
std::fill(tmp.begin(), tmp.end()
|
||||
, (std::numeric_limits<typename Addr::bytes_type::value_type>::max)());
|
||||
, (std::numeric_limits<typename Addr::value_type>::max)());
|
||||
return Addr(tmp);
|
||||
}
|
||||
|
||||
|
@ -220,23 +220,24 @@ namespace detail
|
|||
return i->access;
|
||||
}
|
||||
|
||||
std::vector<ip_range<Addr> > export_filter() const
|
||||
template <class ExternalAddressType>
|
||||
std::vector<ip_range<ExternalAddressType> > export_filter() const
|
||||
{
|
||||
std::vector<ip_range<Addr> > ret;
|
||||
std::vector<ip_range<ExternalAddressType> > ret;
|
||||
ret.reserve(m_access_list.size());
|
||||
|
||||
for (typename range_t::const_iterator i = m_access_list.begin()
|
||||
, end(m_access_list.end()); i != end;)
|
||||
{
|
||||
ip_range<Addr> r;
|
||||
r.first = i->start;
|
||||
ip_range<ExternalAddressType> r;
|
||||
r.first = ExternalAddressType(i->start);
|
||||
r.flags = i->access;
|
||||
|
||||
++i;
|
||||
if (i == end)
|
||||
r.last = max_addr<Addr>();
|
||||
r.last = ExternalAddressType(max_addr<Addr>());
|
||||
else
|
||||
r.last = minus_one(i->start);
|
||||
r.last = ExternalAddressType(minus_one(i->start));
|
||||
|
||||
ret.push_back(r);
|
||||
}
|
||||
|
@ -288,8 +289,8 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
detail::filter_impl<address_v4> m_filter4;
|
||||
detail::filter_impl<address_v6> m_filter6;
|
||||
detail::filter_impl<address_v4::bytes_type> m_filter4;
|
||||
detail::filter_impl<address_v6::bytes_type> m_filter6;
|
||||
};
|
||||
|
||||
class TORRENT_EXPORT port_filter
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
// it will not be mapped
|
||||
void set_mappings(int tcp, int udp);
|
||||
|
||||
void discover_device();
|
||||
void close();
|
||||
|
||||
private:
|
||||
|
@ -89,7 +90,6 @@ private:
|
|||
void resend_request(asio::error_code const& e);
|
||||
void on_reply(udp::endpoint const& from, char* buffer
|
||||
, std::size_t bytes_transferred);
|
||||
void discover_device();
|
||||
|
||||
struct rootdevice;
|
||||
|
||||
|
|
|
@ -62,12 +62,7 @@ namespace libtorrent
|
|||
|
||||
disk_io_thread::~disk_io_thread()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
m_abort = true;
|
||||
m_signal.notify_all();
|
||||
l.unlock();
|
||||
|
||||
m_disk_io_thread.join();
|
||||
TORRENT_ASSERT(m_abort == true);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -95,6 +90,16 @@ namespace libtorrent
|
|||
|
||||
#endif
|
||||
|
||||
void disk_io_thread::join()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
m_abort = true;
|
||||
m_signal.notify_all();
|
||||
l.unlock();
|
||||
|
||||
m_disk_io_thread.join();
|
||||
}
|
||||
|
||||
// aborts read operations
|
||||
void disk_io_thread::stop(boost::intrusive_ptr<piece_manager> s)
|
||||
{
|
||||
|
|
|
@ -44,12 +44,12 @@ namespace libtorrent
|
|||
if (first.is_v4())
|
||||
{
|
||||
TORRENT_ASSERT(last.is_v4());
|
||||
m_filter4.add_rule(first.to_v4(), last.to_v4(), flags);
|
||||
m_filter4.add_rule(first.to_v4().to_bytes(), last.to_v4().to_bytes(), flags);
|
||||
}
|
||||
else if (first.is_v6())
|
||||
{
|
||||
TORRENT_ASSERT(last.is_v6());
|
||||
m_filter6.add_rule(first.to_v6(), last.to_v6(), flags);
|
||||
m_filter6.add_rule(first.to_v6().to_bytes(), last.to_v6().to_bytes(), flags);
|
||||
}
|
||||
else
|
||||
TORRENT_ASSERT(false);
|
||||
|
@ -58,15 +58,15 @@ namespace libtorrent
|
|||
int ip_filter::access(address const& addr) const
|
||||
{
|
||||
if (addr.is_v4())
|
||||
return m_filter4.access(addr.to_v4());
|
||||
return m_filter4.access(addr.to_v4().to_bytes());
|
||||
TORRENT_ASSERT(addr.is_v6());
|
||||
return m_filter6.access(addr.to_v6());
|
||||
return m_filter6.access(addr.to_v6().to_bytes());
|
||||
}
|
||||
|
||||
ip_filter::filter_tuple_t ip_filter::export_filter() const
|
||||
{
|
||||
return boost::make_tuple(m_filter4.export_filter()
|
||||
, m_filter6.export_filter());
|
||||
return boost::make_tuple(m_filter4.export_filter<address_v4>()
|
||||
, m_filter6.export_filter<address_v6>());
|
||||
}
|
||||
|
||||
void port_filter::add_rule(boost::uint16_t first, boost::uint16_t last, int flags)
|
||||
|
|
|
@ -1399,8 +1399,10 @@ namespace libtorrent
|
|||
|
||||
if (t->alerts().should_post(alert::fatal))
|
||||
{
|
||||
std::string err = "torrent paused: disk write error, " + j.str;
|
||||
t->alerts().post_alert(file_error_alert(t->get_handle(), err));
|
||||
if (j.str != "write failed: No space left on device"){
|
||||
std::string err = "torrent paused: disk write error, " + j.str;
|
||||
t->alerts().post_alert(file_error_alert(t->get_handle(), err));
|
||||
}
|
||||
}
|
||||
t->pause();
|
||||
return;
|
||||
|
|
|
@ -533,6 +533,12 @@ namespace libtorrent
|
|||
if (i->second.type == peer::not_connectable) continue;
|
||||
if (i->second.seed && finished) continue;
|
||||
if (i->second.failcount >= max_failcount) continue;
|
||||
|
||||
// prefer peers with lower failcount
|
||||
if (candidate != m_peers.end()
|
||||
&& candidate->second.failcount < i->second.failcount)
|
||||
continue;
|
||||
|
||||
if (now - i->second.connected < seconds(i->second.failcount * min_reconnect_time))
|
||||
continue;
|
||||
if (ses.m_port_filter.access(i->second.ip.port()) & port_filter::blocked)
|
||||
|
|
|
@ -2198,6 +2198,11 @@ namespace detail
|
|||
#endif
|
||||
m_checker_thread->join();
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " waiting for disk io thread\n";
|
||||
#endif
|
||||
m_disk_thread.join();
|
||||
|
||||
TORRENT_ASSERT(m_torrents.empty());
|
||||
TORRENT_ASSERT(m_connections.empty());
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
|
@ -2347,6 +2352,7 @@ namespace detail
|
|||
, bind(&session_impl::on_port_mapping
|
||||
, this, _1, _2, _3));
|
||||
|
||||
m_upnp->discover_device();
|
||||
m_upnp->set_mappings(m_listen_interface.port(),
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
m_dht ? m_dht_settings.service_port :
|
||||
|
|
|
@ -81,7 +81,6 @@ upnp::upnp(io_service& ios, connection_queue& cc
|
|||
m_log.open("upnp.log", std::ios::in | std::ios::out | std::ios::trunc);
|
||||
#endif
|
||||
m_retry_count = 0;
|
||||
discover_device();
|
||||
}
|
||||
|
||||
upnp::~upnp()
|
||||
|
|
Loading…
Reference in New Issue