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
18a001fa
Unverified
Commit
18a001fa
authored
Sep 20, 2022
by
Péter Szilágyi
Committed by
GitHub
Sep 20, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25831 from karalabe/fix-challenge-stop-hang
eth: fix a rare datarace on CHT challenge reply / shutdown
parents
468d1844
d728ba97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
handler.go
eth/handler.go
+14
-4
No files found.
eth/handler.go
View file @
18a001fa
...
...
@@ -391,11 +391,16 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
if
h
.
checkpointHash
!=
(
common
.
Hash
{})
{
// Request the peer's checkpoint header for chain height/weight validation
resCh
:=
make
(
chan
*
eth
.
Response
)
if
_
,
err
:=
peer
.
RequestHeadersByNumber
(
h
.
checkpointNumber
,
1
,
0
,
false
,
resCh
);
err
!=
nil
{
req
,
err
:=
peer
.
RequestHeadersByNumber
(
h
.
checkpointNumber
,
1
,
0
,
false
,
resCh
)
if
err
!=
nil
{
return
err
}
// Start a timer to disconnect if the peer doesn't reply in time
go
func
()
{
// Ensure the request gets cancelled in case of error/drop
defer
req
.
Close
()
timeout
:=
time
.
NewTimer
(
syncChallengeTimeout
)
defer
timeout
.
Stop
()
...
...
@@ -437,10 +442,15 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
// If we have any explicit peer required block hashes, request them
for
number
,
hash
:=
range
h
.
requiredBlocks
{
resCh
:=
make
(
chan
*
eth
.
Response
)
if
_
,
err
:=
peer
.
RequestHeadersByNumber
(
number
,
1
,
0
,
false
,
resCh
);
err
!=
nil
{
req
,
err
:=
peer
.
RequestHeadersByNumber
(
number
,
1
,
0
,
false
,
resCh
)
if
err
!=
nil
{
return
err
}
go
func
(
number
uint64
,
hash
common
.
Hash
)
{
go
func
(
number
uint64
,
hash
common
.
Hash
,
req
*
eth
.
Request
)
{
// Ensure the request gets cancelled in case of error/drop
defer
req
.
Close
()
timeout
:=
time
.
NewTimer
(
syncChallengeTimeout
)
defer
timeout
.
Stop
()
...
...
@@ -469,7 +479,7 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
peer
.
Log
()
.
Warn
(
"Required block challenge timed out, dropping"
,
"addr"
,
peer
.
RemoteAddr
(),
"type"
,
peer
.
Name
())
h
.
removePeer
(
peer
.
ID
())
}
}(
number
,
hash
)
}(
number
,
hash
,
req
)
}
// Handle incoming messages until the connection is torn down
return
handler
(
peer
)
...
...
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