fixed race condition around m_abort in session_impl
This commit is contained in:
parent
f981f6438e
commit
a0cef76bf2
|
@ -33,6 +33,7 @@
|
||||||
incoming connection
|
incoming connection
|
||||||
* added more detailed instrumentation of the disk I/O thread
|
* added more detailed instrumentation of the disk I/O thread
|
||||||
|
|
||||||
|
* fixed race condition around m_abort in session_impl
|
||||||
* fixed bug in web_peer_connection which could cause a hang when downloading
|
* fixed bug in web_peer_connection which could cause a hang when downloading
|
||||||
from web servers
|
from web servers
|
||||||
* fixed bug in metadata extensions combined with encryption
|
* fixed bug in metadata extensions combined with encryption
|
||||||
|
|
|
@ -601,7 +601,7 @@ namespace libtorrent
|
||||||
// set to true when the session object
|
// set to true when the session object
|
||||||
// is being destructed and the thread
|
// is being destructed and the thread
|
||||||
// should exit
|
// should exit
|
||||||
volatile bool m_abort;
|
bool m_abort;
|
||||||
|
|
||||||
// is true if the session is paused
|
// is true if the session is paused
|
||||||
bool m_paused;
|
bool m_paused;
|
||||||
|
|
|
@ -1639,6 +1639,8 @@ namespace aux {
|
||||||
|
|
||||||
if (e == asio::error::operation_aborted) return;
|
if (e == asio::error::operation_aborted) return;
|
||||||
|
|
||||||
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
if (m_abort) return;
|
if (m_abort) return;
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
@ -2935,11 +2937,11 @@ namespace aux {
|
||||||
{
|
{
|
||||||
eh_initializer();
|
eh_initializer();
|
||||||
|
|
||||||
do
|
bool stop_loop = false;
|
||||||
|
while (!stop_loop)
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_io_service.run(ec);
|
m_io_service.run(ec);
|
||||||
TORRENT_ASSERT(m_abort == true);
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
@ -2949,8 +2951,10 @@ namespace aux {
|
||||||
TORRENT_ASSERT(false);
|
TORRENT_ASSERT(false);
|
||||||
}
|
}
|
||||||
m_io_service.reset();
|
m_io_service.reset();
|
||||||
|
|
||||||
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
stop_loop = m_abort;
|
||||||
}
|
}
|
||||||
while (!m_abort);
|
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << time_now_string() << " locking mutex\n";
|
(*m_logger) << time_now_string() << " locking mutex\n";
|
||||||
|
|
Loading…
Reference in New Issue