diff options
| author | Jeff Garzik <[email protected]> | 2012-04-13 18:24:55 -0400 |
|---|---|---|
| committer | Jeff Garzik <[email protected]> | 2012-04-13 18:24:55 -0400 |
| commit | 8deb9822e41602001b399944d8a182f48bc9d088 (patch) | |
| tree | 6f2dde04c144f63dec56de4330c889b9681ae032 /src/main.cpp | |
| parent | Add missing tooltip and key shortcut in settings dialog (#1088 without line b... (diff) | |
| download | discoin-8deb9822e41602001b399944d8a182f48bc9d088.tar.xz discoin-8deb9822e41602001b399944d8a182f48bc9d088.zip | |
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.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index bdafae8eb..c9368cf7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2137,8 +2137,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; |