merge ssl test fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-08-17 22:29:34 +00:00
parent 7e02441a50
commit 023116db6f
3 changed files with 49 additions and 14 deletions

View File

@ -2069,6 +2069,10 @@ namespace aux {
#endif
}
bool reopen_listen_port = false;
if (m_settings.ssl_listen != s.ssl_listen)
reopen_listen_port = true;
m_settings = s;
if (m_settings.cache_buffer_chunk_size <= 0)
@ -2132,6 +2136,12 @@ namespace aux {
while ((i = std::find(i, m_settings.user_agent.end(), '\n'))
!= m_settings.user_agent.end())
*i = ' ';
if (reopen_listen_port)
{
error_code ec;
open_listen_port(0, ec);
}
}
tcp::endpoint session_impl::get_ipv6_interface() const
@ -2223,6 +2233,7 @@ namespace aux {
return;
}
s->external_port = s->sock->local_endpoint(ec).port();
TORRENT_ASSERT(s->external_port == ep.port() || ep.port() == 0);
last_op = listen_failed_alert::get_peer_name;
if (!ec)
{

View File

@ -226,6 +226,8 @@ void wait_for_listen(libtorrent::session& ses, char const* name)
if (listen_done) break;
a = ses.wait_for_alert(milliseconds(500));
} while (a);
// we din't receive a listen alert!
TEST_CHECK(listen_done);
}
void print_ses_rate(float time
@ -440,6 +442,14 @@ boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file, int piece_
&tmp[0], tmp.size(), ec));
}
void update_settings(session_settings& sess_set, bool allow_multiple_ips)
{
if (allow_multiple_ips) sess_set.allow_multiple_connections_per_ip = true;
sess_set.ignore_limits_on_local_network = false;
sess_set.mixed_mode_algorithm = session_settings::prefer_tcp;
sess_set.max_failcount = 1;
}
boost::tuple<torrent_handle, torrent_handle, torrent_handle>
setup_transfer(session* ses1, session* ses2, session* ses3
, bool clear_files, bool use_metadata_transfer, bool connect_peers
@ -458,13 +468,20 @@ setup_transfer(session* ses1, session* ses2, session* ses3
}
session_settings sess_set = ses1->settings();
if (ses3) sess_set.allow_multiple_connections_per_ip = true;
sess_set.ignore_limits_on_local_network = false;
sess_set.mixed_mode_algorithm = session_settings::prefer_tcp;
sess_set.max_failcount = 1;
update_settings(sess_set, ses3);
ses1->set_settings(sess_set);
sess_set = ses2->settings();
update_settings(sess_set, ses3);
ses2->set_settings(sess_set);
if (ses3) ses3->set_settings(sess_set);
if (ses3)
{
sess_set = ses3->settings();
update_settings(sess_set, ses3);
ses3->set_settings(sess_set);
}
ses1->set_alert_mask(~(alert::progress_notification | alert::stats_notification));
ses2->set_alert_mask(~(alert::progress_notification | alert::stats_notification));
if (ses3) ses3->set_alert_mask(~(alert::progress_notification | alert::stats_notification));

View File

@ -107,6 +107,14 @@ void test_ssl(int test_idx)
fprintf(stderr, "\n%s TEST: %s\n\n", time_now_string(), test.name);
#ifndef TORRENT_USE_OPENSSL
if (test.use_ssl_ports)
{
fprintf(stderr, "N/A\n");
return;
}
#endif
// in case the previous run was terminated
error_code ec;
remove_all("tmp1_ssl", ec);
@ -115,16 +123,15 @@ void test_ssl(int test_idx)
session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48075, 49000), "0.0.0.0", 0, alert_mask);
session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000), "0.0.0.0", 0, alert_mask);
wait_for_listen(ses1, "ses1");
wait_for_listen(ses2, "ses2");
session_settings sett;
sett.ssl_listen = 1024 + rand() % 50000;
ses1.set_settings(sett);
if (!test.downloader_has_cert)
// this disables outgoing SSL connections
sett.ssl_listen = 0;
else
sett.ssl_listen += 10;
ses1.set_settings(sett);
sett.ssl_listen += 10;
ses2.set_settings(sett);
torrent_handle tor1;
@ -140,7 +147,7 @@ void test_ssl(int test_idx)
addp.flags &= ~add_torrent_params::flag_auto_managed;
wait_for_listen(ses1, "ses1");
wait_for_listen(ses2, "ses1");
wait_for_listen(ses2, "ses2");
peer_disconnects = 0;
ssl_peer_disconnects = 0;
@ -211,10 +218,10 @@ void test_ssl(int test_idx)
test_sleep(100);
}
fprintf(stderr, "peer_errors: %d\nssl_disconnects: %d\n", peer_errors, ssl_peer_disconnects);
fprintf(stderr, "peer_errors: %d expected: %d\n", peer_errors, test.peer_errors);
TEST_EQUAL(peer_errors, test.peer_errors);
#ifdef TORRENT_USE_OPENSSL
fprintf(stderr, "ssl_disconnects: %d expected: %d\n", ssl_peer_disconnects, test.ssl_disconnects);
TEST_EQUAL(ssl_peer_disconnects, test.ssl_disconnects);
#endif
fprintf(stderr, "%s: EXPECT: %s\n", time_now_string(), test.expected_to_complete ? "SUCCEESS" : "FAILURE");