From: Jeff Garzik Date: Tue, 17 Apr 2012 16:30:00 +0000 (-0400) Subject: AlreadyHave(): only hold lock during mapTransactions access X-Git-Tag: v0.4.0-unstable~129^2~1^2^2~2^2^2~27 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=1175d8f6a1782da777f406a8400b7281a7af09e7 AlreadyHave(): only hold lock during mapTransactions access --- diff --git a/src/main.cpp b/src/main.cpp index 57c18ae..f13b884 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1954,11 +1954,15 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv) 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);