Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
3eca7b5d
Unverified
Commit
3eca7b5d
authored
5 years ago
by
Martin Holst Swende
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: fix data race in downloader
parent
db79143a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
downloader.go
eth/downloader/downloader.go
+16
-19
No files found.
eth/downloader/downloader.go
View file @
3eca7b5d
...
...
@@ -1574,13 +1574,14 @@ func (d *Downloader) importBlockResults(results []*fetchResult) error {
func
(
d
*
Downloader
)
processFastSyncContent
(
latest
*
types
.
Header
)
error
{
// Start syncing state of the reported head block. This should get us most of
// the state of the pivot block.
s
tateS
ync
:=
d
.
syncState
(
latest
.
Root
)
defer
s
tateS
ync
.
Cancel
()
go
func
(
)
{
if
err
:=
s
tateSync
.
Wait
();
err
!=
nil
&&
err
!=
errCancelStateFetch
&&
err
!=
errCanceled
{
sync
:=
d
.
syncState
(
latest
.
Root
)
defer
sync
.
Cancel
()
closeOnErr
:=
func
(
s
*
stateSync
)
{
if
err
:=
s
.
Wait
();
err
!=
nil
&&
err
!=
errCancelStateFetch
&&
err
!=
errCanceled
{
d
.
queue
.
Close
()
// wake up Results
}
}()
}
go
closeOnErr
(
sync
)
// Figure out the ideal pivot block. Note, that this goalpost may move if the
// sync takes long enough for the chain head to move significantly.
pivot
:=
uint64
(
0
)
...
...
@@ -1600,12 +1601,12 @@ func (d *Downloader) processFastSyncContent(latest *types.Header) error {
if
len
(
results
)
==
0
{
// If pivot sync is done, stop
if
oldPivot
==
nil
{
return
s
tateS
ync
.
Cancel
()
return
sync
.
Cancel
()
}
// If sync failed, stop
select
{
case
<-
d
.
cancelCh
:
s
tateS
ync
.
Cancel
()
sync
.
Cancel
()
return
errCanceled
default
:
}
...
...
@@ -1625,28 +1626,24 @@ func (d *Downloader) processFastSyncContent(latest *types.Header) error {
}
}
P
,
beforeP
,
afterP
:=
splitAroundPivot
(
pivot
,
results
)
if
err
:=
d
.
commitFastSyncData
(
beforeP
,
s
tateS
ync
);
err
!=
nil
{
if
err
:=
d
.
commitFastSyncData
(
beforeP
,
sync
);
err
!=
nil
{
return
err
}
if
P
!=
nil
{
// If new pivot block found, cancel old state retrieval and restart
if
oldPivot
!=
P
{
s
tateS
ync
.
Cancel
()
sync
.
Cancel
()
stateSync
=
d
.
syncState
(
P
.
Header
.
Root
)
defer
stateSync
.
Cancel
()
go
func
()
{
if
err
:=
stateSync
.
Wait
();
err
!=
nil
&&
err
!=
errCancelStateFetch
&&
err
!=
errCanceled
{
d
.
queue
.
Close
()
// wake up Results
}
}()
sync
=
d
.
syncState
(
P
.
Header
.
Root
)
defer
sync
.
Cancel
()
go
closeOnErr
(
sync
)
oldPivot
=
P
}
// Wait for completion, occasionally checking for pivot staleness
select
{
case
<-
s
tateS
ync
.
done
:
if
s
tateS
ync
.
err
!=
nil
{
return
s
tateS
ync
.
err
case
<-
sync
.
done
:
if
sync
.
err
!=
nil
{
return
sync
.
err
}
if
err
:=
d
.
commitPivotBlock
(
P
);
err
!=
nil
{
return
err
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment