various cleanup and formatting updates (#1158)
This commit is contained in:
parent
31ce1e5a2c
commit
f592d7fcb0
|
@ -1176,10 +1176,10 @@ namespace libtorrent
|
|||
|
||||
int disk_io_thread::do_read(disk_io_job* j, jobqueue_t& completed_jobs)
|
||||
{
|
||||
int block_size = m_disk_cache.block_size();
|
||||
int piece_size = j->storage->files()->piece_size(j->piece);
|
||||
int blocks_in_piece = (piece_size + block_size - 1) / block_size;
|
||||
int iov_len = m_disk_cache.pad_job(j, blocks_in_piece
|
||||
int const block_size = m_disk_cache.block_size();
|
||||
int const piece_size = j->storage->files()->piece_size(j->piece);
|
||||
int const blocks_in_piece = (piece_size + block_size - 1) / block_size;
|
||||
int const iov_len = m_disk_cache.pad_job(j, blocks_in_piece
|
||||
, m_settings.get_int(settings_pack::read_cache_line_size));
|
||||
|
||||
file::iovec_t* iov = TORRENT_ALLOCA(file::iovec_t, iov_len);
|
||||
|
@ -1213,7 +1213,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// this is the offset that's aligned to block boundaries
|
||||
std::int64_t adjusted_offset = j->d.io.offset & ~(block_size-1);
|
||||
std::int64_t const adjusted_offset = j->d.io.offset & ~(block_size-1);
|
||||
|
||||
// if this is the last piece, adjust the size of the
|
||||
// last buffer to match up
|
||||
|
|
|
@ -544,6 +544,8 @@ namespace libtorrent
|
|||
int const num_allowed_pieces = m_settings.get_int(settings_pack::allowed_fast_set_size);
|
||||
if (num_allowed_pieces == 0) return;
|
||||
|
||||
if (!t->valid_metadata()) return;
|
||||
|
||||
int const num_pieces = t->torrent_file().num_pieces();
|
||||
|
||||
if (num_allowed_pieces >= num_pieces)
|
||||
|
@ -2441,7 +2443,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
void peer_connection::incoming_piece_fragment(int bytes)
|
||||
void peer_connection::incoming_piece_fragment(int const bytes)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
m_last_piece = aux::time_now();
|
||||
|
@ -3385,7 +3387,7 @@ namespace libtorrent
|
|||
return true;
|
||||
}
|
||||
|
||||
bool peer_connection::add_request(piece_block const& block, int flags)
|
||||
bool peer_connection::add_request(piece_block const& block, int const flags)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
INVARIANT_CHECK;
|
||||
|
@ -4727,7 +4729,7 @@ namespace libtorrent
|
|||
// if we can't read, it means we're blocked on the rate-limiter
|
||||
// or the disk, not the peer itself. In this case, don't blame
|
||||
// the peer and disconnect it
|
||||
bool may_timeout = (m_channel_state[download_channel] & peer_info::bw_network) != 0;
|
||||
bool const may_timeout = (m_channel_state[download_channel] & peer_info::bw_network) != 0;
|
||||
|
||||
// TODO: 2 use a deadline_timer for timeouts. Don't rely on second_tick()!
|
||||
// Hook this up to connect timeout as well. This would improve performance
|
||||
|
|
|
@ -84,7 +84,7 @@ void receive_buffer::grow(int const limit)
|
|||
m_watermark = sliding_average<20>();
|
||||
}
|
||||
|
||||
int receive_buffer::advance_pos(int bytes)
|
||||
int receive_buffer::advance_pos(int const bytes)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
int const limit = m_packet_size > m_recv_pos ? m_packet_size - m_recv_pos : m_packet_size;
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace libtorrent
|
|||
// also, if we already have at least one outstanding
|
||||
// request, we shouldn't pick any busy pieces either
|
||||
// in time critical mode, it's OK to request busy blocks
|
||||
bool dont_pick_busy_blocks
|
||||
bool const dont_pick_busy_blocks
|
||||
= ((ses.settings().get_bool(settings_pack::strict_end_game_mode)
|
||||
&& p.get_download_queue_size() < p.num_want_left())
|
||||
|| dq.size() + rq.size() > 0)
|
||||
|
|
|
@ -1102,8 +1102,7 @@ namespace libtorrent
|
|||
read_fileop op(*this, flags);
|
||||
|
||||
#ifdef TORRENT_SIMULATE_SLOW_READ
|
||||
boost::thread::sleep(boost::get_system_time()
|
||||
+ boost::posix_time::milliseconds(1000));
|
||||
std::this_thread::sleep_for(seconds(1));
|
||||
#endif
|
||||
return readwritev(files(), bufs.data(), piece, offset, int(bufs.size()), op, ec);
|
||||
}
|
||||
|
|
|
@ -1047,7 +1047,9 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (should_log())
|
||||
{
|
||||
debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str()
|
||||
debug_log("disk error: (%d) %s [%s : %s] in file: %s"
|
||||
, j->error.ec.value(), j->error.ec.message().c_str()
|
||||
, job_name(j->action), j->error.operation_str()
|
||||
, resolve_filename(j->error.file).c_str());
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -110,7 +110,7 @@ static void nop() {}
|
|||
INITIALIZE_JOB(wj) \
|
||||
rj.storage = pm; \
|
||||
wj.storage = pm; \
|
||||
cached_piece_entry* pe = NULL; \
|
||||
cached_piece_entry* pe = nullptr; \
|
||||
int ret = 0; \
|
||||
file::iovec_t iov[1]; \
|
||||
(void)iov[0]; \
|
||||
|
|
|
@ -51,6 +51,10 @@ void check_chain(tailqueue<test_node>& chain, char const* expected)
|
|||
i.next();
|
||||
++expected;
|
||||
}
|
||||
if (!chain.empty())
|
||||
{
|
||||
TEST_CHECK(chain.last() == nullptr || chain.last()->next == nullptr);
|
||||
}
|
||||
TEST_EQUAL(expected[0], 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue