forked from premiere/premiere-libtorrent
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:
commit
d332a03281
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue