diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-23 01:13:18 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-23 01:13:18 +0800 |
commit | 3ce17d2862e89e20b8e9b10cc02ee0b1333f6625 (patch) | |
tree | d097f70879be2914e65175ded76c9c850cbf529e /eth/fetcher | |
parent | 99ca4b619b22c000dfe633b036ed0b9b0fe83523 (diff) | |
download | dexon-3ce17d2862e89e20b8e9b10cc02ee0b1333f6625.tar.gz dexon-3ce17d2862e89e20b8e9b10cc02ee0b1333f6625.tar.zst dexon-3ce17d2862e89e20b8e9b10cc02ee0b1333f6625.zip |
eth/fetcher: fix a closure data race
Diffstat (limited to 'eth/fetcher')
-rw-r--r-- | eth/fetcher/fetcher.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/eth/fetcher/fetcher.go b/eth/fetcher/fetcher.go index 7b5804ab2..90a202235 100644 --- a/eth/fetcher/fetcher.go +++ b/eth/fetcher/fetcher.go @@ -281,12 +281,13 @@ func (f *Fetcher) loop() { glog.V(logger.Detail).Infof("Peer %s: fetching %s", peer, list) } - hashes := hashes // closure! + // Create a closure of the fetch and schedule in on a new thread + fetcher, hashes := f.fetching[hashes[0]].fetch, hashes go func() { if f.fetchingHook != nil { f.fetchingHook(hashes) } - f.fetching[hashes[0]].fetch(hashes) + fetcher(hashes) }() } // Schedule the next fetch if blocks are still pending |