lt sync 2219

This commit is contained in:
Andrew Resch 2008-04-23 01:14:11 +00:00
parent e477b5e037
commit 9f05f6fc64
8 changed files with 58 additions and 12 deletions

View File

@ -119,6 +119,19 @@ namespace
s.start_upnp(); s.start_upnp();
return; return;
} }
list get_torrents(session& s)
{
list ret;
std::vector<torrent_handle> torrents = s.get_torrents();
for (std::vector<torrent_handle>::iterator i = torrents.begin(); i != torrents.end(); ++i)
{
ret.append(*i);
}
return ret;
}
#ifndef TORRENT_DISABLE_GEO_IP #ifndef TORRENT_DISABLE_GEO_IP
bool load_asnum_db(session& s, std::string file) bool load_asnum_db(session& s, std::string file)
{ {
@ -298,6 +311,8 @@ void bind_session()
.def("start_natpmp", &start_natpmp, session_start_natpmp_doc) .def("start_natpmp", &start_natpmp, session_start_natpmp_doc)
.def("stop_natpmp", allow_threads(&session::stop_natpmp), session_stop_natpmp_doc) .def("stop_natpmp", allow_threads(&session::stop_natpmp), session_stop_natpmp_doc)
.def("set_ip_filter", allow_threads(&session::set_ip_filter), session_set_ip_filter_doc) .def("set_ip_filter", allow_threads(&session::set_ip_filter), session_set_ip_filter_doc)
.def("find_torrent", allow_threads(&session::find_torrent))
.def("get_torrents", &get_torrents)
; ;
register_ptr_to_python<std::auto_ptr<alert> >(); register_ptr_to_python<std::auto_ptr<alert> >();

View File

@ -203,6 +203,7 @@ namespace libtorrent
#endif #endif
#ifndef TORRENT_DISABLE_GEO_IP #ifndef TORRENT_DISABLE_GEO_IP
int as_for_ip(address const& addr);
bool load_asnum_db(char const* file); bool load_asnum_db(char const* file);
bool load_country_db(char const* file); bool load_country_db(char const* file);
#endif #endif

View File

@ -526,7 +526,14 @@ namespace libtorrent
// optimization, don't send have messages // optimization, don't send have messages
// to peers that already have the piece // to peers that already have the piece
if (!m_ses.settings().send_redundant_have if (!m_ses.settings().send_redundant_have
&& has_piece(index)) return; && has_piece(index))
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string()
<< " ==> HAVE [ piece: " << index << " ] SUPRESSED\n";
#endif
return;
}
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()

View File

@ -185,6 +185,13 @@ namespace libtorrent
{ {
return m_impl->load_country_db(file); return m_impl->load_country_db(file);
} }
int session::as_for_ip(address const& addr)
{
aux::session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
return m_impl->as_for_ip(addr);
}
#endif #endif
void session::load_state(entry const& ses_state) void session::load_state(entry const& ses_state)

View File

@ -159,7 +159,7 @@ namespace aux {
, m_num_unchoked(0) , m_num_unchoked(0)
, m_unchoke_time_scaler(0) , m_unchoke_time_scaler(0)
, m_optimistic_unchoke_time_scaler(0) , m_optimistic_unchoke_time_scaler(0)
, m_disconnect_time_scaler(0) , m_disconnect_time_scaler(90)
, m_incoming_connection(false) , m_incoming_connection(false)
, m_last_tick(time_now()) , m_last_tick(time_now())
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
@ -1355,7 +1355,7 @@ namespace aux {
--m_disconnect_time_scaler; --m_disconnect_time_scaler;
if (m_disconnect_time_scaler <= 0) if (m_disconnect_time_scaler <= 0)
{ {
m_disconnect_time_scaler = 60; m_disconnect_time_scaler = 90;
// every 60 seconds, disconnect the worst peer // every 60 seconds, disconnect the worst peer
// if we have reached the connection limit // if we have reached the connection limit
@ -1366,6 +1366,7 @@ namespace aux {
< bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _2))); < bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _2)));
TORRENT_ASSERT(i != m_torrents.end()); TORRENT_ASSERT(i != m_torrents.end());
// TODO: make the number of peers a percentage of the number of connected peers
i->second->get_policy().disconnect_one_peer(); i->second->get_policy().disconnect_one_peer();
} }
} }
@ -1565,13 +1566,6 @@ namespace aux {
m_queued_for_checking.pop_front(); m_queued_for_checking.pop_front();
if (!m_queued_for_checking.empty()) if (!m_queued_for_checking.empty())
m_queued_for_checking.front()->start_checking(); m_queued_for_checking.front()->start_checking();
if (m_alerts.should_post(alert::info))
{
m_alerts.post_alert(torrent_checked_alert(
t->get_handle()
, "torrent finished checking"));
}
} }
torrent_handle session_impl::add_torrent( torrent_handle session_impl::add_torrent(

View File

@ -206,6 +206,10 @@ namespace libtorrent
, m_max_connections((std::numeric_limits<int>::max)()) , m_max_connections((std::numeric_limits<int>::max)())
, m_deficit_counter(0) , m_deficit_counter(0)
, m_policy(this) , m_policy(this)
, m_active_time(seconds(0))
, m_seeding_time(seconds(0))
, m_total_uploaded(0)
, m_total_downloaded(0)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_files_checked = false; m_files_checked = false;
@ -271,6 +275,10 @@ namespace libtorrent
, m_max_connections((std::numeric_limits<int>::max)()) , m_max_connections((std::numeric_limits<int>::max)())
, m_deficit_counter(0) , m_deficit_counter(0)
, m_policy(this) , m_policy(this)
, m_active_time(seconds(0))
, m_seeding_time(seconds(0))
, m_total_uploaded(0)
, m_total_downloaded(0)
{ {
#ifndef NDEBUG #ifndef NDEBUG
m_files_checked = false; m_files_checked = false;
@ -1149,7 +1157,9 @@ namespace libtorrent
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_ses.m_logger) << time_now_string() << " *** PIECE_FINISHED [ p: " (*m_ses.m_logger) << time_now_string() << " *** PIECE_FINISHED [ p: "
<< index << " chk: " << (passed_hash_check?"passed":"failed") << " ]\n"; << index << " chk: " << ((passed_hash_check == 0)
?"passed":passed_hash_check == -1
?"disk failed":"failed") << " ]\n";
#endif #endif
bool was_seed = is_seed(); bool was_seed = is_seed();
@ -2981,6 +2991,14 @@ namespace libtorrent
#endif #endif
} }
} }
if (m_ses.m_alerts.should_post(alert::info))
{
m_ses.m_alerts.post_alert(torrent_checked_alert(
get_handle()
, "torrent finished checking"));
}
#ifndef NDEBUG #ifndef NDEBUG
m_files_checked = true; m_files_checked = true;
#endif #endif

View File

@ -24,6 +24,8 @@ udp_socket::udp_socket(asio::io_service& ios, udp_socket::callback_t const& c
void udp_socket::send(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec) void udp_socket::send(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec)
{ {
if (ec == asio::error::operation_aborted) return;
if (m_tunnel_packets) if (m_tunnel_packets)
{ {
// send udp packets through SOCKS5 server // send udp packets through SOCKS5 server
@ -39,6 +41,8 @@ void udp_socket::send(udp::endpoint const& ep, char const* p, int len, asio::err
void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t bytes_transferred) void udp_socket::on_read(udp::socket* s, asio::error_code const& e, std::size_t bytes_transferred)
{ {
if (e == asio::error::operation_aborted) return;
if (!m_callback) return; if (!m_callback) return;
if (e) if (e)

View File

@ -84,7 +84,7 @@ namespace libtorrent
: tracker_connection(man, req, ios, bind_infc, c) : tracker_connection(man, req, ios, bind_infc, c)
, m_man(man) , m_man(man)
, m_name_lookup(ios) , m_name_lookup(ios)
, m_socket(ios, boost::bind(&udp_tracker_connection::on_receive, this, _1, _2, _3, _4), cc) , m_socket(ios, boost::bind(&udp_tracker_connection::on_receive, self(), _1, _2, _3, _4), cc)
, m_transaction_id(0) , m_transaction_id(0)
, m_connection_id(0) , m_connection_id(0)
, m_settings(stn) , m_settings(stn)