diff --git a/libi2pd/NetDbRequests.cpp b/libi2pd/NetDbRequests.cpp index b04cb5d0..3e4d4eb3 100644 --- a/libi2pd/NetDbRequests.cpp +++ b/libi2pd/NetDbRequests.cpp @@ -31,6 +31,7 @@ namespace data std::shared_ptr RequestedDestination::CreateRequestMessage (std::shared_ptr router, std::shared_ptr replyTunnel) { + std::lock_guard l (m_ExcludedPeerstMutex); std::shared_ptr msg; if(replyTunnel) msg = i2p::CreateRouterInfoDatabaseLookupMsg (m_Destination, @@ -53,8 +54,15 @@ namespace data return msg; } + bool RequestedDestination::IsExcluded (const IdentHash& ident) const + { + std::lock_guard l (m_ExcludedPeerstMutex); + return m_ExcludedPeers.count (ident); + } + void RequestedDestination::ClearExcludedPeers () { + std::lock_guard l (m_ExcludedPeerstMutex); m_ExcludedPeers.clear (); } diff --git a/libi2pd/NetDbRequests.h b/libi2pd/NetDbRequests.h index a9997ad7..1d50ee79 100644 --- a/libi2pd/NetDbRequests.h +++ b/libi2pd/NetDbRequests.h @@ -36,12 +36,12 @@ namespace data const IdentHash& GetDestination () const { return m_Destination; }; int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); }; - const std::set& GetExcludedPeers () { return m_ExcludedPeers; }; + const std::set& GetExcludedPeers () const { return m_ExcludedPeers; }; void ClearExcludedPeers (); bool IsExploratory () const { return m_IsExploratory; }; bool IsDirect () const { return m_IsDirect; }; bool IsActive () const { return m_IsActive; }; - bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); }; + bool IsExcluded (const IdentHash& ident) const; uint64_t GetCreationTime () const { return m_CreationTime; }; uint64_t GetLastRequestTime () const { return m_LastRequestTime; }; std::shared_ptr CreateRequestMessage (std::shared_ptr, std::shared_ptr replyTunnel); @@ -57,6 +57,7 @@ namespace data IdentHash m_Destination; bool m_IsExploratory, m_IsDirect, m_IsActive; + mutable std::mutex m_ExcludedPeerstMutex; std::set m_ExcludedPeers; uint64_t m_CreationTime, m_LastRequestTime; // in seconds RequestComplete m_RequestComplete;