forked from premiere/premiere-libtorrent
fixed a long standing (quite rare) bug, thanks to Massaroddel. Made the tests clean up their temporary files.
This commit is contained in:
parent
db4ca12c02
commit
d3ba5edd6d
|
@ -316,6 +316,7 @@ namespace libtorrent
|
||||||
peer_connection::~peer_connection()
|
peer_connection::~peer_connection()
|
||||||
{
|
{
|
||||||
// INVARIANT_CHECK;
|
// INVARIANT_CHECK;
|
||||||
|
assert(m_disconnecting);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
using namespace boost::posix_time;
|
using namespace boost::posix_time;
|
||||||
|
|
|
@ -599,6 +599,8 @@ namespace libtorrent { namespace detail
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
c->disconnect();
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << "connect failed [" << c->remote() << "]: "
|
(*m_logger) << "connect failed [" << c->remote() << "]: "
|
||||||
<< e.what() << "\n";
|
<< e.what() << "\n";
|
||||||
|
@ -750,8 +752,10 @@ namespace libtorrent { namespace detail
|
||||||
// has to be in the queue, waiting to be connected.
|
// has to be in the queue, waiting to be connected.
|
||||||
connection_queue::iterator j = std::find(
|
connection_queue::iterator j = std::find(
|
||||||
m_connection_queue.begin(), m_connection_queue.end(), p);
|
m_connection_queue.begin(), m_connection_queue.end(), p);
|
||||||
|
|
||||||
assert(j != m_connection_queue.end());
|
// if this connection was closed while being connected
|
||||||
|
// it has been removed from the connection queue and
|
||||||
|
// not yet put into the half-open queue.
|
||||||
if (j != m_connection_queue.end())
|
if (j != m_connection_queue.end())
|
||||||
m_connection_queue.erase(j);
|
m_connection_queue.erase(j);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1073,6 +1073,7 @@ namespace libtorrent
|
||||||
c->disconnect();
|
c->disconnect();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
if (c->is_disconnecting()) throw protocol_error("failed to connect");
|
||||||
return *c;
|
return *c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,8 @@ void test_transfer(bool clear_files = true, bool disconnect = false)
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
// test to disconnect one client prematurely
|
// test to disconnect one client prematurely
|
||||||
test_transfer(true, true);
|
test_transfer(true, true);
|
||||||
|
|
||||||
|
@ -65,6 +66,9 @@ int test_main()
|
||||||
// test where both have data (to trigger the file check)
|
// test where both have data (to trigger the file check)
|
||||||
test_transfer(false);
|
test_transfer(false);
|
||||||
|
|
||||||
|
remove_all("./tmp1");
|
||||||
|
remove_all("./tmp2");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,8 @@ int test_main()
|
||||||
pm.read(piece, 2, 0, piece_size);
|
pm.read(piece, 2, 0, piece_size);
|
||||||
TEST_CHECK(std::equal(piece, piece + piece_size, piece2));
|
TEST_CHECK(std::equal(piece, piece + piece_size, piece2));
|
||||||
|
|
||||||
|
remove_all(initial_path() / "temp_storage");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue