fixed a long standing (quite rare) bug, thanks to Massaroddel. Made the tests clean up their temporary files.

This commit is contained in:
Arvid Norberg 2006-06-24 22:30:59 +00:00
parent db4ca12c02
commit d3ba5edd6d
5 changed files with 15 additions and 3 deletions

View File

@ -316,6 +316,7 @@ namespace libtorrent
peer_connection::~peer_connection()
{
// INVARIANT_CHECK;
assert(m_disconnecting);
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;

View File

@ -599,6 +599,8 @@ namespace libtorrent { namespace detail
}
catch (std::exception& e)
{
c->disconnect();
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << "connect failed [" << c->remote() << "]: "
<< e.what() << "\n";
@ -750,8 +752,10 @@ namespace libtorrent { namespace detail
// has to be in the queue, waiting to be connected.
connection_queue::iterator j = std::find(
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())
m_connection_queue.erase(j);
}

View File

@ -1073,6 +1073,7 @@ namespace libtorrent
c->disconnect();
throw;
}
if (c->is_disconnecting()) throw protocol_error("failed to connect");
return *c;
}

View File

@ -55,7 +55,8 @@ void test_transfer(bool clear_files = true, bool disconnect = false)
int test_main()
{
using namespace libtorrent;
using namespace boost::filesystem;
// test to disconnect one client prematurely
test_transfer(true, true);
@ -65,6 +66,9 @@ int test_main()
// test where both have data (to trigger the file check)
test_transfer(false);
remove_all("./tmp1");
remove_all("./tmp2");
return 0;
}

View File

@ -99,6 +99,8 @@ int test_main()
pm.read(piece, 2, 0, piece_size);
TEST_CHECK(std::equal(piece, piece + piece_size, piece2));
remove_all(initial_path() / "temp_storage");
return 0;
}