don't print stuff to stdout in debug builds. when waking up from completing a connection attempt, exit immediately if the connection is disconnecting, or disconnect if we're in graceful pause mode. some test cleanups

This commit is contained in:
Arvid Norberg 2014-01-26 08:18:13 +00:00
parent f0d1e8636c
commit 36c9add067
4 changed files with 44 additions and 20 deletions

View File

@ -159,6 +159,20 @@ namespace libtorrent
void bt_peer_connection::on_connected()
{
if (is_disconnecting()) return;
boost::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t);
if (t->graceful_pause())
{
#ifdef TORRENT_VERBOSE_LOGGING
peer_log("*** ON_CONNECTED [ graceful-paused ]");
#endif
disconnect(error_code(errors::torrent_paused), 0);
return;
}
#ifndef TORRENT_DISABLE_ENCRYPTION
boost::uint8_t out_enc_policy = m_ses.get_pe_settings().out_enc_policy;

View File

@ -1389,9 +1389,6 @@ namespace libtorrent
j.str.clear();
j.error = ec;
j.error_file = j.storage->error_file();
#ifdef TORRENT_DEBUG
printf("ERROR: '%s' in %s\n", ec.message().c_str(), j.error_file.c_str());
#endif
j.storage->clear_error();
return true;
}

View File

@ -279,25 +279,29 @@ void print_ses_rate(float time
, libtorrent::torrent_status const* st2
, libtorrent::torrent_status const* st3)
{
fprintf(stderr, "%3.1fs | %dkB/s %dkB/s %d%% %d", time
fprintf(stderr, "%3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
, int(st1->download_payload_rate / 1000)
, int(st1->upload_payload_rate / 1000)
, int(st1->progress * 100)
, st1->num_peers);
, st1->num_peers
, st1->connect_candidates
, st1->error.empty() ? "" : (" [" + st1->error + "]").c_str());
if (st2)
std::cerr << " : "
<< int(st2->download_payload_rate / 1000.f) << "kB/s "
<< int(st2->upload_payload_rate / 1000.f) << "kB/s "
<< int(st2->progress * 100) << "% "
<< st2->num_peers
<< " cc: " << st2->connect_candidates;
fprintf(stderr, " : %3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
, int(st2->download_payload_rate / 1000)
, int(st2->upload_payload_rate / 1000)
, int(st2->progress * 100)
, st2->num_peers
, st2->connect_candidates
, st2->error.empty() ? "" : (" [" + st2->error + "]").c_str());
if (st3)
std::cerr << " : "
<< int(st3->download_payload_rate / 1000.f) << "kB/s "
<< int(st3->upload_payload_rate / 1000.f) << "kB/s "
<< int(st3->progress * 100) << "% "
<< st3->num_peers
<< " cc: " << st3->connect_candidates;
fprintf(stderr, " : %3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
, int(st3->download_payload_rate / 1000)
, int(st3->upload_payload_rate / 1000)
, int(st3->progress * 100)
, st3->num_peers
, st3->connect_candidates
, st3->error.empty() ? "" : (" [" + st3->error + "]").c_str());
fprintf(stderr, "\n");
}

View File

@ -172,6 +172,7 @@ storage_interface* test_storage_constructor(file_storage const& fs
void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowed_fast = false)
{
static int listen_port = 0;
char const* test_name[] = {"no", "SOCKS4", "SOCKS5", "SOCKS5 password", "HTTP", "HTTP password"};
@ -191,8 +192,11 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
session_proxy p1;
session_proxy p2;
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);
session ses1(fingerprint("LT", 0, 1, 0, 0)
, std::make_pair(48075 + listen_port, 49000), "0.0.0.0", 0, alert_mask);
session ses2(fingerprint("LT", 0, 1, 0, 0)
, std::make_pair(49075 + listen_port, 50000), "0.0.0.0", 0, alert_mask);
++listen_port;
proxy_settings ps;
if (proxy_type)
@ -316,11 +320,16 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
// upload mode to false
test_sleep(500);
// then we need to drain the alert queue, so the peer_disconnects
// counter doesn't get incremented by old alerts
print_alerts(ses1, "ses1", true, true, true, &on_alert);
print_alerts(ses2, "ses2", true, true, true, &on_alert);
tor2.set_upload_mode(false);
TEST_CHECK(tor2.status().is_finished == false);
TEST_EQUAL(peer_disconnects, 2);
fprintf(stderr, "%s: discovered disk full mode. Raise limit and disable upload-mode\n", time_now_string());
peer_disconnects = -1;
peer_disconnects = 0;
test_sleep(100);
continue;
}