aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2012-04-13 18:24:55 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-04-17 13:20:29 -0400
commit12570da46ff9de4201ae9f3411db0e955d2993de (patch)
treebd3142ebc30446ce93db4542979a694d1a6852e8 /src/main.cpp
parent8460185dec74383b1e49500683cfc7aa9ceba554 (diff)
downloadbitcoin-12570da46ff9de4201ae9f3411db0e955d2993de.tar.xz
Locking fix for AlreadyHave()
Access to mapTransactions[] must be guarded by cs_mapTransactions lock.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 059dd3db9e..57c18aed48 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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