Skip to content

Commit d6e3ebe

Browse files
practicalswiftfurszy
authored andcommitted
tests: Add missing locking annotations and locks
1 parent 3b7c9e5 commit d6e3ebe

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct COrphanTx {
3737
NodeId fromPeer;
3838
int64_t nTimeExpire;
3939
};
40-
static RecursiveMutex g_cs_orphans;
40+
RecursiveMutex g_cs_orphans;
4141
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
4242
std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans);
4343

src/test/DoS_tests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ struct COrphanTx {
3333
NodeId fromPeer;
3434
int64_t nTimeExpire;
3535
};
36-
extern std::map<uint256, COrphanTx> mapOrphanTransactions;
36+
extern RecursiveMutex g_cs_orphans;
37+
extern std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
3738

3839
CService ip(uint32_t i)
3940
{
@@ -135,6 +136,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
135136
CTransactionRef RandomOrphan()
136137
{
137138
std::map<uint256, COrphanTx>::iterator it;
139+
LOCK2(cs_main, g_cs_orphans);
138140
it = mapOrphanTransactions.lower_bound(InsecureRand256());
139141
if (it == mapOrphanTransactions.end())
140142
it = mapOrphanTransactions.begin();
@@ -220,6 +222,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
220222
BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i));
221223
}
222224

225+
LOCK2(cs_main, g_cs_orphans);
223226
// Test EraseOrphansFor:
224227
for (NodeId i = 0; i < 3; i++)
225228
{

0 commit comments

Comments
 (0)