Skip to content

Commit

Permalink
tsan: fix race in inactive_votes_cache_multiple_votes (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocode authored Oct 10, 2019
1 parent 2d4a1ff commit a0b4977
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion nano/core_test/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,15 @@ TEST (active_transactions, inactive_votes_cache_multiple_votes)
auto vote2 (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, std::vector<nano::block_hash> (1, send1->hash ())));
system.nodes[0]->vote_processor.vote (vote2, std::make_shared<nano::transport::channel_udp> (system.nodes[0]->network.udp_channels, system.nodes[0]->network.endpoint (), system.nodes[0]->network_params.protocol.protocol_version));
system.deadline_set (5s);
while (system.nodes[0]->active.find_inactive_votes_cache (send1->hash ()).voters.size () != 2)
while (true)
{
{
nano::lock_guard<std::mutex> active_guard (system.nodes[0]->active.mutex);
if (system.nodes[0]->active.find_inactive_votes_cache (send1->hash ()).voters.size () == 2)
{
break;
}
}
ASSERT_NO_ERROR (system.poll ());
}
ASSERT_EQ (1, system.nodes[0]->active.inactive_votes_cache_size ());
Expand Down
3 changes: 2 additions & 1 deletion nano/node/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ void nano::active_transactions::request_confirm (nano::unique_lock<std::mutex> &
// Batched confirmation requests
if (!batched_confirm_req_bundle_l.empty ())
{
node.network.broadcast_confirm_req_batched_many (batched_confirm_req_bundle_l, [this]() {
node.network.broadcast_confirm_req_batched_many (
batched_confirm_req_bundle_l, [this]() {
{
nano::lock_guard<std::mutex> guard_l (this->mutex);
--this->ongoing_broadcasts;
Expand Down
4 changes: 2 additions & 2 deletions nano/secure/versioning.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <nano/secure/versioning.hpp>

#include <lmdb/libraries/liblmdb/lmdb.h>

#include <boost/endian/conversion.hpp>

#include <lmdb/libraries/liblmdb/lmdb.h>

nano::account_info_v1::account_info_v1 (MDB_val const & val_a)
{
assert (val_a.mv_size == sizeof (*this));
Expand Down

0 comments on commit a0b4977

Please sign in to comment.