Mercurial > hg > bitcoin
changeset 2229:769fdad63e31 draft
Locking fix for AlreadyHave()
Access to mapTransactions[] must be guarded by cs_mapTransactions lock.
Also, reformat long lines to make the switch statement more readable.
author | Jeff Garzik <jeff@garzik.org> |
---|---|
date | Fri, 13 Apr 2012 18:24:55 -0400 |
parents | 90a0623bca82 |
children | 3a7cadc1b470 |
files | src/main.cpp |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.cpp +++ b/src/main.cpp @@ -2137,8 +2137,17 @@ { 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;