allow 0 upload slots. added test for allow fast support for sending pieces to choked peers

This commit is contained in:
Arvid Norberg 2009-06-20 23:23:41 +00:00
parent c47f9cd64c
commit 93e1c70263
4 changed files with 31 additions and 24 deletions

View File

@ -66,6 +66,7 @@ release 0.14.5
* fix to make torrent_status::list_peers more accurate.
* fixed memory leak in disk io thread when not using the cache
* fixed bug in connect candidate counter
* allow 0 upload slots
release 0.14.4

View File

@ -241,7 +241,7 @@ can use the service simultaneously. This is controlled by
In order to always unchoke peers, turn off automatic unchoke
``session_settings::auto_upload_slots`` and set the number of upload slots to a large
number via ``session::set_max_uploads()``.
number via ``session::set_max_uploads()``, or use -1 (which means infinite).
torrent limits
--------------

View File

@ -2648,7 +2648,7 @@ namespace aux {
INVARIANT_CHECK;
if (limit <= 0) limit = (std::numeric_limits<int>::max)();
if (limit < 0) limit = (std::numeric_limits<int>::max)();
if (m_max_uploads == limit) return;
m_max_uploads = limit;
m_allowed_upload_slots = limit;
@ -2952,7 +2952,7 @@ namespace aux {
std::set<peer_connection*> unique_peers;
TORRENT_ASSERT(m_max_connections > 0);
TORRENT_ASSERT(m_max_uploads > 0);
TORRENT_ASSERT(m_max_uploads >= 0);
if (!m_settings.auto_upload_slots_rate_based || !m_settings.auto_upload_slots)
TORRENT_ASSERT(m_allowed_upload_slots >= m_max_uploads);
int unchokes = 0;

View File

@ -51,6 +51,12 @@ using boost::tuples::ignore;
// test the maximum transfer rate
void test_rate()
{
// in case the previous run was terminated
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48575, 49000), "0.0.0.0", 0);
session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49575, 50000), "0.0.0.0", 0);
@ -203,11 +209,25 @@ storage_interface* test_storage_constructor(file_storage const& fs
return new test_storage(fs, path, fp);
}
void test_transfer(bool test_disk_full = false)
void test_transfer(bool test_disk_full = false, bool test_allowed_fast = false)
{
// in case the previous run was terminated
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48075, 49000), "0.0.0.0", 0);
session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000), "0.0.0.0", 0);
if (test_allowed_fast)
{
session_settings sett;
sett.allowed_fast_set_size = 2000;
ses1.set_max_uploads(0);
ses1.set_settings(sett);
}
#ifndef TORRENT_DISABLE_ENCRYPTION
pe_settings pes;
pes.out_enc_policy = pe_settings::forced;
@ -435,33 +455,19 @@ int test_main()
using namespace libtorrent;
using namespace boost::filesystem;
// in case the previous run was terminated
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
// test with a (simulated) full disk
test_transfer(true);
return 0;
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
#ifdef NDEBUG
// test rate only makes sense in release mode
test_rate();
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
#endif
test_transfer();
// test with a (simulated) full disk
test_transfer(true);
// test allowed fast
test_transfer(false, true);
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}