Merge pull request #512 from arvidn/connect-speed-1.1

increase default connect speed. minor cleanup. add logging for short …
This commit is contained in:
Arvid Norberg 2016-03-03 18:10:03 -05:00
commit d332a03281
5 changed files with 43 additions and 58 deletions

View File

@ -2287,11 +2287,6 @@ int main(int argc, char* argv[])
}
}
// keep track of the number of resume data
// alerts to wait for
int num_paused = 0;
int num_failed = 0;
ses.pause();
printf("saving resume data\n");
std::vector<torrent_status> temp;
@ -2334,38 +2329,12 @@ int main(int argc, char* argv[])
for (std::vector<alert*>::iterator i = alerts.begin()
, end(alerts.end()); i != end; ++i)
{
torrent_paused_alert* tp = alert_cast<torrent_paused_alert>(*i);
if (tp)
if (!::handle_alert(ses, *i, files, non_files))
{
++num_paused;
printf("\rleft: %d failed: %d pause: %d "
, num_outstanding_resume_data, num_failed, num_paused);
continue;
// if we didn't handle the alert, print it to the log
std::string event_string;
print_alert(*i, event_string);
}
if (alert_cast<save_resume_data_failed_alert>(*i))
{
++num_failed;
--num_outstanding_resume_data;
printf("\rleft: %d failed: %d pause: %d "
, num_outstanding_resume_data, num_failed, num_paused);
continue;
}
save_resume_data_alert* rd = alert_cast<save_resume_data_alert>(*i);
if (!rd) continue;
--num_outstanding_resume_data;
printf("\rleft: %d failed: %d pause: %d "
, num_outstanding_resume_data, num_failed, num_paused);
if (!rd->resume_data) continue;
torrent_handle h = rd->handle;
torrent_status st = h.status(torrent_handle::query_save_path);
std::vector<char> out;
bencode(std::back_inserter(out), *rd->resume_data);
save_file(path_append(st.save_path, path_append(".resume"
, leaf_path(hash_to_filename[st.info_hash]) + ".resume")), out);
}
}

View File

@ -589,7 +589,7 @@ namespace libtorrent
bool can_disconnect(error_code const& ec) const;
void incoming_dht_port(int listen_port);
void incoming_reject_request(peer_request const& r);
void incoming_have_all();
void incoming_have_none();

View File

@ -808,7 +808,7 @@ namespace libtorrent
// we support FAST extension
*(ptr + 7) |= 0x04;
#ifndef TORRENT_DISABLE_LOGGING
#ifndef TORRENT_DISABLE_LOGGING
std::string bitmask;
for (int k = 0; k < 8; ++k)
{
@ -3285,7 +3285,7 @@ namespace libtorrent
recv_buffer = m_recv_buffer.get();
#ifndef TORRENT_DISABLE_LOGGING
#ifndef TORRENT_DISABLE_LOGGING
std::string extensions;
extensions.resize(8 * 8);
for (int i=0; i < 8; ++i)
@ -3461,7 +3461,7 @@ namespace libtorrent
#endif
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::incoming_message, "HANDSHAKE");
peer_log(peer_log_alert::incoming_message, "HANDSHAKE", "connection ready");
#endif
// consider this a successful connection, reset the failcount
if (peer_info_struct())

View File

@ -803,7 +803,7 @@ namespace libtorrent
m_connected = false;
if (!m_download_queue.empty())
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
// defensive
boost::shared_ptr<torrent> t = m_torrent.lock();
// if t is NULL, we better not be connecting, since
@ -990,13 +990,13 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
return m_request_queue;
}
std::vector<pending_block> const& peer_connection::download_queue() const
{
TORRENT_ASSERT(is_single_thread());
return m_download_queue;
}
std::vector<peer_request> const& peer_connection::upload_queue() const
{
TORRENT_ASSERT(is_single_thread());
@ -1878,7 +1878,7 @@ namespace libtorrent
m_have_piece.set_bit(index);
++m_num_pieces;
// if the peer is downloading stuff, it must have metadata
// if the peer is downloading stuff, it must have metadata
m_has_metadata = true;
// only update the piece_picker if
@ -2576,9 +2576,9 @@ namespace libtorrent
{
check_postcondition(boost::shared_ptr<torrent> const& t_
, bool init_check = true): t(t_) { if (init_check) check(); }
~check_postcondition() { check(); }
void check()
{
if (!t->is_seed())
@ -2596,7 +2596,7 @@ namespace libtorrent
}
}
}
shared_ptr<torrent> t;
};
#endif
@ -3229,7 +3229,7 @@ namespace libtorrent
disconnect_if_redundant();
}
// -----------------------------
// --------- HAVE NONE ---------
// -----------------------------
@ -3495,8 +3495,8 @@ namespace libtorrent
if (t->alerts().should_post<block_downloading_alert>())
{
t->alerts().emplace_alert<block_downloading_alert>(t->get_handle(),
remote(), pid(), block.block_index, block.piece_index);
t->alerts().emplace_alert<block_downloading_alert>(t->get_handle()
, remote(), pid(), block.block_index, block.piece_index);
}
pending_block pb(block);
@ -3643,6 +3643,8 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK;
TORRENT_ASSERT(!is_connecting());
if (m_choked)
{
TORRENT_ASSERT(m_peer_info == NULL
@ -4082,6 +4084,15 @@ namespace libtorrent
, op, ec.message().c_str());
break;
}
if (ec == error_code(boost::asio::error::eof
, boost::asio::error::get_misc_category())
&& !in_handshake()
&& !is_connecting()
&& clock_type::now() - connected_time() < seconds(15))
{
peer_log(peer_log_alert::info, "SHORT_LIVED_DISCONNECT", "");
}
#endif
if ((m_channel_state[upload_channel] & peer_info::bw_network) == 0)
@ -4955,8 +4966,8 @@ namespace libtorrent
boost::int64_t piece_size = t->torrent_file().piece_length();
if (m_remote_dl_rate > 0)
m_remote_dl_rate = int((m_remote_dl_rate * 2 / 3) +
((boost::int64_t(m_remote_pieces_dled) * piece_size / 3) / 60));
m_remote_dl_rate = int((m_remote_dl_rate * 2 / 3)
+ ((boost::int64_t(m_remote_pieces_dled) * piece_size / 3) / 60));
else
m_remote_dl_rate = int(boost::int64_t(m_remote_pieces_dled)
* piece_size / 60);
@ -5355,7 +5366,7 @@ namespace libtorrent
disconnect(j->error.ec, op_file_read);
return;
}
if (j->ret != r.length)
{
// handle_disk_error may disconnect us
@ -5715,7 +5726,7 @@ namespace libtorrent
{
return;
}
if (!can_read())
{
#ifndef TORRENT_DISABLE_LOGGING
@ -5980,8 +5991,11 @@ namespace libtorrent
if (error)
{
TORRENT_ASSERT_VAL(error.value() != 0, error.value());
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::info, "ERROR", "in peer_connection::on_receive_data_nb error: %s"
peer_log(peer_log_alert::info, "ERROR"
, "in peer_connection::on_receive_data_nb error: (%s:%d) %s"
, error.category().name(), error.value()
, error.message().c_str());
#endif
on_receive(error, bytes_transferred);
@ -6106,8 +6120,10 @@ namespace libtorrent
{
TORRENT_ASSERT(is_single_thread());
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::incoming, "ON_RECEIVE_DATA", "bytes: %d error: %s"
, int(bytes_transferred), error.message().c_str());
peer_log(peer_log_alert::incoming, "ON_RECEIVE_DATA"
, "bytes: %d error: (%s:%d) %s"
, int(bytes_transferred), error.category().name(), error.value()
, error.message().c_str());
#endif
// submit all disk jobs later
@ -6836,7 +6852,7 @@ namespace libtorrent
time_duration d;
d = aux::time_now() - m_last_sent;
if (total_seconds(d) < timeout() / 2) return;
if (m_connecting) return;
if (in_handshake()) return;

View File

@ -233,7 +233,7 @@ namespace libtorrent
SET(max_failcount, 3, &session_impl::update_max_failcount),
SET(min_reconnect_time, 60, 0),
SET(peer_connect_timeout, 15, 0),
SET(connection_speed, 6, &session_impl::update_connection_speed),
SET(connection_speed, 10, &session_impl::update_connection_speed),
SET(inactivity_timeout, 600, 0),
SET(unchoke_interval, 15, 0),
SET(optimistic_unchoke_interval, 30, 0),