From 848fdbc28a3ef123da9a655e6a8eb89b46f1129a Mon Sep 17 00:00:00 2001 From: clemahieu Date: Tue, 4 Nov 2014 22:15:36 -0600 Subject: [PATCH] Adding mutex around work. --- rai/core/core.cpp | 3 +++ rai/core/core.hpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rai/core/core.cpp b/rai/core/core.cpp index 63b426f5..2d526044 100644 --- a/rai/core/core.cpp +++ b/rai/core/core.cpp @@ -261,6 +261,7 @@ void rai::network::receive_action (boost::system::error_code const & error, size receive (); if (!error) { + std::lock_guard lock (work_mutex); if (!work.validate (client.store.root (*incoming.block), incoming.work)) { ++publish_req_count; @@ -289,6 +290,7 @@ void rai::network::receive_action (boost::system::error_code const & error, size receive (); if (!error) { + std::lock_guard lock (work_mutex); if (!work.validate (client.store.root (*incoming.block), incoming.work)) { ++confirm_req_count; @@ -317,6 +319,7 @@ void rai::network::receive_action (boost::system::error_code const & error, size receive (); if (!error) { + std::lock_guard lock (work_mutex); if (!work.validate (client.store.root (*incoming.vote.block), incoming.work)) { ++confirm_ack_count; diff --git a/rai/core/core.hpp b/rai/core/core.hpp index ba174283..574f76de 100644 --- a/rai/core/core.hpp +++ b/rai/core/core.hpp @@ -473,12 +473,13 @@ namespace rai { rai::endpoint remote; std::array buffer; rai::work work; + std::mutex work_mutex; boost::asio::ip::udp::socket socket; + std::mutex socket_mutex; boost::asio::io_service & service; boost::asio::ip::udp::resolver resolver; rai::client & client; std::queue >> sends; - std::mutex mutex; uint64_t keepalive_count; uint64_t publish_req_count; uint64_t confirm_req_count;