aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-04-17 09:23:49 -0700
committerJeff Garzik <jgarzik@exmulti.com>2012-04-17 09:23:49 -0700
commitdd21ce5f1bb690e6104d8eba30cbd4b8749bf6b0 (patch)
treeaffadc04c40fbe547d7aeb6f3b2594f495c084aa
parentea9627979e172dd1d13e9f1a4b4185bb820fcfe8 (diff)
parent8deb9822e41602001b399944d8a182f48bc9d088 (diff)
downloadbitcoin-dd21ce5f1bb690e6104d8eba30cbd4b8749bf6b0.tar.xz
Merge pull request #1094 from jgarzik/already-have-locking
Locking fix for AlreadyHave()
-rw-r--r--src/main.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 11bcdc83fe..449f4bd372 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2135,8 +2135,17 @@ 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_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash);
+ case MSG_TX:
+ {
+ LOCK(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
return true;