Skip to content

Commit bdbd654

Browse files
author
MarcoFalke
committed
Merge #14108: tests: Add missing locking annotations and locks (g_cs_orphans)
b602c9b tests: Add missing locking annotations and locks (practicalswift) Pull request description: Add missing locking annotations and locks. `mapOrphanTransactions` is guarded by `g_cs_orphans`. Tree-SHA512: f95104fbef23bd385e754c6bea3c3bdddd8a9c6a68e719d761227c9be1e46ff1316ec050a15a1243218dbab4e8584da6674f4a72f949f54b0a758392f19c83f8
2 parents 3f96908 + b602c9b commit bdbd654

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct COrphanTx {
7070
NodeId fromPeer;
7171
int64_t nTimeExpire;
7272
};
73-
static CCriticalSection g_cs_orphans;
73+
CCriticalSection g_cs_orphans;
7474
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
7575

7676
void EraseOrphansFor(NodeId peer);

src/test/denialofservice_tests.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ struct COrphanTx {
3131
NodeId fromPeer;
3232
int64_t nTimeExpire;
3333
};
34-
extern std::map<uint256, COrphanTx> mapOrphanTransactions;
34+
extern CCriticalSection g_cs_orphans;
35+
extern std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
3536

3637
static CService ip(uint32_t i)
3738
{
@@ -324,7 +325,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
324325
static CTransactionRef RandomOrphan()
325326
{
326327
std::map<uint256, COrphanTx>::iterator it;
327-
LOCK(cs_main);
328+
LOCK2(cs_main, g_cs_orphans);
328329
it = mapOrphanTransactions.lower_bound(InsecureRand256());
329330
if (it == mapOrphanTransactions.end())
330331
it = mapOrphanTransactions.begin();
@@ -394,7 +395,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
394395
BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i));
395396
}
396397

397-
LOCK(cs_main);
398+
LOCK2(cs_main, g_cs_orphans);
398399
// Test EraseOrphansFor:
399400
for (NodeId i = 0; i < 3; i++)
400401
{

0 commit comments

Comments
 (0)