changeset 2925:e9ac7cee99d1 draft

Locking fix for AlreadyHave() Access to mapTransactions[] must be guarded by cs_mapTransactions lock.
author Jeff Garzik <jeff@garzik.org>
date Fri, 13 Apr 2012 18:24:55 -0400
parents e7753ff7b516
children eebe6cd0e3bd
files src/main.cpp
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1953,7 +1953,14 @@
 {
     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