converted some recursive mutexes to regular ones
This commit is contained in:
@@ -90,7 +90,11 @@ namespace libtorrent
|
||||
e->ticket = m_next_ticket;
|
||||
e->timeout = timeout;
|
||||
++m_next_ticket;
|
||||
try_connect();
|
||||
|
||||
if (m_num_connecting < m_half_open_limit
|
||||
|| m_half_open_limit == 0)
|
||||
m_timer.get_io_service().post(boost::bind(
|
||||
&connection_queue::on_try_connect, this));
|
||||
}
|
||||
|
||||
void connection_queue::done(int ticket)
|
||||
@@ -108,7 +112,11 @@ namespace libtorrent
|
||||
}
|
||||
if (i->connecting) --m_num_connecting;
|
||||
m_queue.erase(i);
|
||||
try_connect();
|
||||
|
||||
if (m_num_connecting < m_half_open_limit
|
||||
|| m_half_open_limit == 0)
|
||||
m_timer.get_io_service().post(boost::bind(
|
||||
&connection_queue::on_try_connect, this));
|
||||
}
|
||||
|
||||
void connection_queue::close()
|
||||
@@ -126,7 +134,13 @@ namespace libtorrent
|
||||
m_queue.pop_front();
|
||||
if (e.connecting) --m_num_connecting;
|
||||
l.unlock();
|
||||
try { e.on_timeout(); } catch (std::exception&) {}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
e.on_timeout();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
l.lock();
|
||||
}
|
||||
}
|
||||
@@ -155,9 +169,10 @@ namespace libtorrent
|
||||
|
||||
#endif
|
||||
|
||||
void connection_queue::try_connect()
|
||||
void connection_queue::try_connect(connection_queue::mutex_t::scoped_lock& l)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(l.owns_lock());
|
||||
|
||||
#ifdef TORRENT_CONNECTION_LOGGING
|
||||
m_log << log_time() << " " << free_slots() << std::endl;
|
||||
@@ -206,6 +221,8 @@ namespace libtorrent
|
||||
i = std::find_if(i, m_queue.end(), boost::bind(&entry::connecting, _1) == false);
|
||||
}
|
||||
|
||||
l.unlock();
|
||||
|
||||
while (!to_connect.empty())
|
||||
{
|
||||
entry& ent = to_connect.front();
|
||||
@@ -218,6 +235,7 @@ namespace libtorrent
|
||||
#endif
|
||||
to_connect.pop_front();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
@@ -268,7 +286,13 @@ namespace libtorrent
|
||||
for (std::list<entry>::iterator i = timed_out.begin()
|
||||
, end(timed_out.end()); i != end; ++i)
|
||||
{
|
||||
try { i->on_timeout(); } catch (std::exception&) {}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
i->on_timeout();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (std::exception&) {}
|
||||
#endif
|
||||
}
|
||||
|
||||
l.lock();
|
||||
@@ -279,8 +303,13 @@ namespace libtorrent
|
||||
m_timer.expires_at(next_expire, ec);
|
||||
m_timer.async_wait(boost::bind(&connection_queue::on_timeout, this, _1));
|
||||
}
|
||||
try_connect();
|
||||
try_connect(l);
|
||||
}
|
||||
|
||||
void connection_queue::on_try_connect()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
try_connect(l);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user