Locking fix for AlreadyHave()

Access to mapTransactions[] must be guarded by cs_mapTransactions lock.
This commit is contained in:
Jeff Garzik
2012-04-13 18:24:55 -04:00
committed by Luke Dashjr
parent 8460185dec
commit 12570da46f

View File

@@ -1953,7 +1953,14 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv)
{
switch (inv.type)
{
case MSG_TX: return mapTransactions.count(inv.hash) || mapOrphanTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash);
case MSG_TX:
CRITICAL_BLOCK(cs_mapTransactions)
{
return mapTransactions.count(inv.hash) ||
mapOrphanTransactions.count(inv.hash) ||
txdb.ContainsTx(inv.hash);
}
case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash);
}
// Don't know what it is, just say we already got one