merged ssl fix from RC_0_16
This commit is contained in:
@@ -53,6 +53,15 @@ int const alert_mask = alert::all_categories
|
||||
& ~alert::progress_notification
|
||||
& ~alert::stats_notification;
|
||||
|
||||
int peer_disconnects = 0;
|
||||
|
||||
bool predicate(alert* a)
|
||||
{
|
||||
if (peer_disconnected_alert* p = alert_cast<peer_disconnected_alert>(a))
|
||||
++peer_disconnects;
|
||||
return false;
|
||||
}
|
||||
|
||||
// test the maximum transfer rate
|
||||
void test_rate()
|
||||
{
|
||||
@@ -77,15 +86,17 @@ void test_rate()
|
||||
wait_for_listen(ses1, "ses1");
|
||||
wait_for_listen(ses2, "ses1");
|
||||
|
||||
peer_disconnects = 0;
|
||||
|
||||
boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
|
||||
, true, false, true, "_transfer", 0, &t);
|
||||
|
||||
ptime start = time_now();
|
||||
|
||||
for (int i = 0; i < 70; ++i)
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
print_alerts(ses1, "ses1");
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses1, "ses1", true, true, true, &predicate);
|
||||
print_alerts(ses2, "ses2", true, true, true, &predicate);
|
||||
|
||||
torrent_status st1 = tor1.status();
|
||||
torrent_status st2 = tor2.status();
|
||||
@@ -93,6 +104,7 @@ void test_rate()
|
||||
if (i % 10 == 0)
|
||||
print_ses_rate(i / 10.f, &st1, &st2);
|
||||
|
||||
if (peer_disconnects == 2) break;
|
||||
if (st2.is_seeding) break;
|
||||
test_sleep(100);
|
||||
}
|
||||
@@ -221,6 +233,10 @@ bool on_alert(alert* a)
|
||||
{
|
||||
if (alert_cast<tracker_reply_alert>(a))
|
||||
++tracker_responses;
|
||||
|
||||
if (alert_cast<peer_disconnected_alert>(a))
|
||||
++peer_disconnects;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -326,6 +342,8 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
||||
wait_for_listen(ses1, "ses1");
|
||||
wait_for_listen(ses2, "ses1");
|
||||
|
||||
peer_disconnects = 0;
|
||||
|
||||
// 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);
|
||||
@@ -398,6 +416,8 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
||||
TEST_CHECK(st2.state == torrent_status::downloading
|
||||
|| (test_disk_full && !st2.error.empty()));
|
||||
|
||||
if (peer_disconnects == 2) break;
|
||||
|
||||
test_sleep(100);
|
||||
}
|
||||
|
||||
@@ -416,10 +436,13 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
||||
std::cerr << "force recheck" << std::endl;
|
||||
tor2.force_recheck();
|
||||
|
||||
peer_disconnects = 0;
|
||||
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
test_sleep(100);
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses2, "ses2", true, true, true, on_alert);
|
||||
|
||||
torrent_status st2 = tor2.status();
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
@@ -433,7 +456,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses2, "ses2", true, true, true, on_alert);
|
||||
torrent_status st2 = tor2.status();
|
||||
TEST_CHECK(st2.state == torrent_status::finished);
|
||||
test_sleep(100);
|
||||
@@ -509,8 +532,8 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
print_alerts(ses1, "ses1");
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses1, "ses1", true, true, true, on_alert);
|
||||
print_alerts(ses2, "ses2", true, true, true, on_alert);
|
||||
|
||||
torrent_status st1 = tor1.status();
|
||||
torrent_status st2 = tor2.status();
|
||||
@@ -529,8 +552,8 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
||||
|
||||
for (int i = 0; i < 130; ++i)
|
||||
{
|
||||
print_alerts(ses1, "ses1");
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses1, "ses1", true, true, true, on_alert);
|
||||
print_alerts(ses2, "ses2", true, true, true, on_alert);
|
||||
|
||||
torrent_status st1 = tor1.status();
|
||||
torrent_status st2 = tor2.status();
|
||||
|
Reference in New Issue
Block a user