Skip to content

Commit 3ce17d2

Browse files
committed
eth/fetcher: fix a closure data race
1 parent 99ca4b6 commit 3ce17d2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

eth/fetcher/fetcher.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,13 @@ func (f *Fetcher) loop() {
281281

282282
glog.V(logger.Detail).Infof("Peer %s: fetching %s", peer, list)
283283
}
284-
hashes := hashes // closure!
284+
// Create a closure of the fetch and schedule in on a new thread
285+
fetcher, hashes := f.fetching[hashes[0]].fetch, hashes
285286
go func() {
286287
if f.fetchingHook != nil {
287288
f.fetchingHook(hashes)
288289
}
289-
f.fetching[hashes[0]].fetch(hashes)
290+
fetcher(hashes)
290291
}()
291292
}
292293
// Schedule the next fetch if blocks are still pending

0 commit comments

Comments
 (0)