forked from premiere/premiere-libtorrent
fixed storage bug
This commit is contained in:
parent
557b3f3955
commit
811c073c1b
|
@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
bool sleep_and_input(char* c)
|
||||
{
|
||||
Sleep(1000);
|
||||
Sleep(200);
|
||||
if (kbhit())
|
||||
{
|
||||
*c = getch();
|
||||
|
@ -112,7 +112,7 @@ bool sleep_and_input(char* c)
|
|||
fd_set set;
|
||||
FD_ZERO(&set);
|
||||
FD_SET(0, &set);
|
||||
timeval tv = {1, 0};
|
||||
timeval tv = {0, 200000};
|
||||
if (select(1, &set, 0, 0, &tv) > 0)
|
||||
{
|
||||
*c = getc(stdin);
|
||||
|
@ -294,10 +294,24 @@ int main(int argc, char* argv[])
|
|||
<< static_cast<const char*>((i->flags & peer_info::choked)?"C":"_")
|
||||
<< static_cast<const char*>((i->flags & peer_info::remote_interested)?"i":"_")
|
||||
<< static_cast<const char*>((i->flags & peer_info::remote_choked)?"c":"_") << "\n";
|
||||
|
||||
if (i->downloading_piece_index >= 0)
|
||||
{
|
||||
out << i->downloading_piece_index << ";"
|
||||
<< i->downloading_block_index << ": ";
|
||||
float progress = i->downloading_progress / static_cast<float>(i->downloading_total);
|
||||
for (int j = 0; j < 20; ++j)
|
||||
{
|
||||
if (progress * 20 > j) out << "#";
|
||||
else out << "-";
|
||||
}
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
out << "___________________________________\n";
|
||||
|
||||
/*
|
||||
i->get_download_queue(queue);
|
||||
for (std::vector<partial_piece_info>::iterator i = queue.begin();
|
||||
i != queue.end();
|
||||
|
@ -316,6 +330,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
out << "___________________________________\n";
|
||||
*/
|
||||
}
|
||||
|
||||
clear();
|
||||
|
|
|
@ -1288,6 +1288,7 @@ namespace {
|
|||
{
|
||||
static std::ofstream log("log.txt");
|
||||
log << s;
|
||||
log.flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1825,15 +1826,7 @@ namespace libtorrent {
|
|||
m_info.piece_size(
|
||||
m_info.num_pieces() - 1);
|
||||
|
||||
// treat the last slot as unallocated space.
|
||||
// this means that when we get to the last
|
||||
// slot we are either allocating space for
|
||||
// the last piece, or the last piece has already
|
||||
// been allocated
|
||||
if (current_piece == m_info.num_pieces() - 1)
|
||||
m_unallocated_slots.push_back(current_piece);
|
||||
else
|
||||
m_free_slots.push_back(current_piece);
|
||||
m_free_slots.push_back(current_piece);
|
||||
}
|
||||
|
||||
// done with piece, move on to next
|
||||
|
@ -1869,6 +1862,8 @@ namespace libtorrent {
|
|||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
check_invariant();
|
||||
|
||||
assert(piece_index >= 0 && piece_index < m_piece_to_slot.size());
|
||||
assert(m_piece_to_slot.size() == m_slot_to_piece.size());
|
||||
|
||||
|
@ -1895,6 +1890,7 @@ namespace libtorrent {
|
|||
|
||||
if (iter == m_free_slots.end())
|
||||
{
|
||||
assert(m_slot_to_piece[piece_index] != -2);
|
||||
iter = m_free_slots.end() - 1;
|
||||
|
||||
// special case to make sure we don't use the last slot
|
||||
|
@ -1978,6 +1974,8 @@ namespace libtorrent {
|
|||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
check_invariant();
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
std::cout << "allocating pieces...\n";
|
||||
|
@ -2043,6 +2041,16 @@ namespace libtorrent {
|
|||
{
|
||||
if (m_piece_to_slot[i] != i && m_piece_to_slot[i] >= 0)
|
||||
assert(m_slot_to_piece[i] == -1);
|
||||
|
||||
if (m_slot_to_piece[i] == -2)
|
||||
{
|
||||
assert(
|
||||
std::find(
|
||||
m_free_slots.begin()
|
||||
, m_free_slots.end()
|
||||
, i) != m_free_slots.end()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue