changeset 2926:eebe6cd0e3bd draft

AlreadyHave(): only hold lock during mapTransactions access
author Jeff Garzik <jeff@garzik.org>
date Tue, 17 Apr 2012 12:30:00 -0400
parents e9ac7cee99d1
children 6d1897505a0f
files src/main.cpp
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1954,11 +1954,15 @@
     switch (inv.type)
     {
     case MSG_TX:
+        {
+        bool txInMap = false;
         CRITICAL_BLOCK(cs_mapTransactions)
         {
-            return mapTransactions.count(inv.hash) ||
-                   mapOrphanTransactions.count(inv.hash) ||
-                   txdb.ContainsTx(inv.hash);
+            txInMap = (mapTransactions.count(inv.hash) != 0);
+        }
+        return txInMap ||
+               mapOrphanTransactions.count(inv.hash) ||
+               txdb.ContainsTx(inv.hash);
         }
 
     case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash);