Commit 3ce17d28 authored by Péter Szilágyi's avatar Péter Szilágyi

eth/fetcher: fix a closure data race

parent 99ca4b61
...@@ -281,12 +281,13 @@ func (f *Fetcher) loop() { ...@@ -281,12 +281,13 @@ func (f *Fetcher) loop() {
glog.V(logger.Detail).Infof("Peer %s: fetching %s", peer, list) 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() { go func() {
if f.fetchingHook != nil { if f.fetchingHook != nil {
f.fetchingHook(hashes) f.fetchingHook(hashes)
} }
f.fetching[hashes[0]].fetch(hashes) fetcher(hashes)
}() }()
} }
// Schedule the next fetch if blocks are still pending // Schedule the next fetch if blocks are still pending
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment