merged storage allocation mode fix from RC_0_16

This commit is contained in:
Arvid Norberg 2014-02-07 08:58:52 +00:00
parent 6c22d426d4
commit 0398dfe498
4 changed files with 23 additions and 5 deletions

View File

@ -40,6 +40,7 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* fix crash when using full allocation storage mode
* improve error_code and error_category support in python bindings
* fix python binding for external_ip_alert

View File

@ -1272,7 +1272,7 @@ int main(int argc, char* argv[])
#endif
" -l <limit> sets the listen socket queue size\n"
"\n DISK OPTIONS\n"
" -a <mode> sets the allocation mode. [sparse|full]\n"
" -a <mode> sets the allocation mode. [sparse|allocate]\n"
" -R <num blocks> number of blocks per read cache line\n"
" -C <limit> sets the max cache size. Specified in 16kB blocks\n"
" -O Disallow disk job reordering\n"
@ -1398,7 +1398,8 @@ int main(int argc, char* argv[])
case 'S': settings.unchoke_slots_limit = atoi(arg); break;
case 'a':
if (strcmp(arg, "allocate") == 0) allocation_mode = storage_mode_allocate;
if (strcmp(arg, "sparse") == 0) allocation_mode = storage_mode_sparse;
else if (strcmp(arg, "full") == 0) allocation_mode = storage_mode_allocate;
else if (strcmp(arg, "sparse") == 0) allocation_mode = storage_mode_sparse;
break;
case 's': save_path = arg; break;
case 'U': torrent_upload_limit = atoi(arg) * 1000; break;

View File

@ -1223,7 +1223,7 @@ ret:
// if the file has priority 0, don't allocate it
if (m_allocate_files && (op.mode & file::rw_mask) != file::read_only
&& (m_file_priority.size() < file_index || m_file_priority[file_index] > 0))
&& (m_file_priority.size() <= file_index || m_file_priority[file_index] > 0))
{
TORRENT_ASSERT(m_file_created.size() == files().num_files());
if (m_file_created[file_index] == false)
@ -2953,6 +2953,8 @@ ret:
int piece_manager::slot_for(int piece) const
{
if (m_storage_mode != internal_storage_mode_compact_deprecated) return piece;
// this happens in seed mode, where we skip checking fastresume
if (m_piece_to_slot.empty()) return piece;
TORRENT_ASSERT(piece < int(m_piece_to_slot.size()));
TORRENT_ASSERT(piece >= 0);
return m_piece_to_slot[piece];

View File

@ -170,7 +170,9 @@ storage_interface* test_storage_constructor(file_storage const& fs
return new test_storage(fs, path, fp);
}
void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowed_fast = false)
void test_transfer(int proxy_type, bool test_disk_full = false
, bool test_allowed_fast = false
, storage_mode_t storage_mode = storage_mode_sparse)
{
static int listen_port = 0;
@ -269,6 +271,9 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
addp.flags &= ~add_torrent_params::flag_paused;
addp.flags &= ~add_torrent_params::flag_auto_managed;
add_torrent_params params;
params.storage_mode = storage_mode;
wait_for_listen(ses1, "ses1");
wait_for_listen(ses2, "ses1");
@ -276,7 +281,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
// test using piece sizes smaller than 16kB
boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
, true, false, true, "_transfer", 8 * 1024, &t, false, test_disk_full?&addp:0);
, true, false, true, "_transfer", 8 * 1024, &t, false, test_disk_full?&addp:&params);
int num_pieces = tor2.torrent_file()->num_pieces();
std::vector<int> priorities(num_pieces, 1);
@ -380,6 +385,15 @@ int test_main()
// test allowed fast
test_transfer(0, false, true);
// test storage_mode_allocate
fprintf(stderr, "full allocation mode\n");
test_transfer(0, false, false, storage_mode_allocate);
#ifndef TORRENT_NO_DEPRECATE
fprintf(stderr, "compact mode\n");
test_transfer(0, false, false, storage_mode_compact);
#endif
error_code ec;
remove_all("tmp1_transfer", ec);