From 399c4d6ac4bcd1c9ef3f3d229f7e757f7f6471eb Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 9 Oct 2008 03:32:57 +0000 Subject: [PATCH] mutex fix for dht status reporting --- include/libtorrent/kademlia/node.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index 8808d10fb..ffbe4ddc7 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/socket.hpp" @@ -235,10 +236,16 @@ public: int branch_factor() const { return m_settings.search_branching; } void add_traversal_algorithm(traversal_algorithm* a) - { m_running_requests.insert(a); } + { + mutex_t::scoped_lock l(m_mutex); + m_running_requests.insert(a); + } void remove_traversal_algorithm(traversal_algorithm* a) - { m_running_requests.erase(a); } + { + mutex_t::scoped_lock l(m_mutex); + m_running_requests.erase(a); + } void status(libtorrent::session_status& s); @@ -260,6 +267,9 @@ protected: int m_max_peers_reply; private: + typedef boost::mutex mutex_t; + mutex_t m_mutex; + // this list must be destructed after the rpc manager // since it might have references to it std::set m_running_requests;