From 3ce17d2862e89e20b8e9b10cc02ee0b1333f6625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 22 Jun 2015 20:13:18 +0300 Subject: eth/fetcher: fix a closure data race --- eth/fetcher/fetcher.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'eth') 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 -- cgit v1.2.3