attempt to make setup_transfer more reliable by waiting for torrents to transition to downloading state before connecting peers

This commit is contained in:
arvidn 2015-06-15 22:00:02 -04:00
parent bd2bcf12bc
commit c1913a97f3
2 changed files with 24 additions and 24 deletions

View File

@ -321,7 +321,7 @@ bool downloading_done = false;
bool downloading_alert(libtorrent::alert const* a)
{
state_changed_alert const* sc = alert_cast<state_changed_alert>(a);
if (sc && sc->state == torrent_status::downloading)
if (sc && sc->state == torrent_status::downloading)
downloading_done = true;
return true;
}
@ -795,13 +795,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
if (connect_peers)
{
std::auto_ptr<alert> a;
/* do
{
a = wait_for_alert(*ses2, state_changed_alert::alert_type, "ses2");
} while (static_cast<state_changed_alert*>(a.get())->state != torrent_status::downloading);
*/
// wait_for_alert(*ses1, torrent_finished_alert::alert_type, "ses1");
wait_for_downloading(*ses2, "ses2");
error_code ec;
int port = 0;
@ -821,6 +815,8 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
// give the other peers some time to get an initial
// set of pieces before they start sharing with each-other
wait_for_downloading(*ses3, "ses3");
port = 0;
int port2 = 0;
if (use_ssl_ports)

View File

@ -511,33 +511,37 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse)
p2 = ses2.abort();
}
using namespace libtorrent;
TORRENT_TEST(remap_files)
{
using namespace libtorrent;
error_code ec;
remove_all("tmp1_remap", ec);
remove_all("tmp2_remap", ec);
test_remap_files_gather();
error_code ec;
remove_all("tmp1_remap", ec);
remove_all("tmp2_remap", ec);
remove_all("tmp1_remap2", ec);
remove_all("tmp2_remap2", ec);
}
TORRENT_TEST(scatter)
{
test_remap_files_scatter();
remove_all("tmp1_remap", ec);
remove_all("tmp2_remap", ec);
remove_all("tmp1_remap2", ec);
remove_all("tmp2_remap2", ec);
remove_all("tmp1_remap3", ec);
remove_all("tmp2_remap3", ec);
test_remap_files_prio();
error_code ec;
remove_all("tmp1_remap", ec);
remove_all("tmp2_remap", ec);
remove_all("tmp1_remap2", ec);
remove_all("tmp2_remap2", ec);
remove_all("tmp1_remap3", ec);
remove_all("tmp2_remap3", ec);
}
TORRENT_TEST(prio)
{
test_remap_files_prio();
error_code ec;
remove_all("tmp1_remap", ec);
remove_all("tmp2_remap", ec);
remove_all("tmp1_remap2", ec);