made connection_queue thread safe
This commit is contained in:
parent
140fdae5b1
commit
777bb87a55
|
@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <list>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
|
||||
|
@ -88,6 +89,10 @@ private:
|
|||
int m_half_open_limit;
|
||||
|
||||
deadline_timer m_timer;
|
||||
|
||||
typedef boost::recursive_mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool m_in_timeout_function;
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace libtorrent
|
|||
, boost::function<void()> const& on_timeout
|
||||
, time_duration timeout)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
m_queue.push_back(entry());
|
||||
|
@ -68,6 +70,8 @@ namespace libtorrent
|
|||
|
||||
void connection_queue::done(int ticket)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
std::list<entry>::iterator i = std::find_if(m_queue.begin()
|
||||
|
@ -105,6 +109,8 @@ namespace libtorrent
|
|||
|
||||
void connection_queue::try_connect()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (!free_slots() || m_queue.empty())
|
||||
|
@ -148,6 +154,8 @@ namespace libtorrent
|
|||
|
||||
void connection_queue::on_timeout(asio::error_code const& e)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
#ifndef NDEBUG
|
||||
function_guard guard_(m_in_timeout_function);
|
||||
|
|
Loading…
Reference in New Issue