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
a0ac3b6a
Commit
a0ac3b6a
authored
Jan 29, 2019
by
Ferenc Szabo
Committed by
Anton Evangelatov
Jan 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/protocols: fix rare data race in Peer.Handshake() (#18951)
parent
e9daed18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
protocol.go
p2p/protocols/protocol.go
+4
-1
No files found.
p2p/protocols/protocol.go
View file @
a0ac3b6a
...
...
@@ -386,10 +386,12 @@ func (p *Peer) handleIncoming(handle func(ctx context.Context, msg interface{})
// * the dialing peer needs to send the handshake first and then waits for remote
// * the listening peer waits for the remote handshake and then sends it
// returns the remote handshake and an error
func
(
p
*
Peer
)
Handshake
(
ctx
context
.
Context
,
hs
interface
{},
verify
func
(
interface
{})
error
)
(
rhs
interface
{},
err
error
)
{
func
(
p
*
Peer
)
Handshake
(
ctx
context
.
Context
,
hs
interface
{},
verify
func
(
interface
{})
error
)
(
interface
{},
error
)
{
if
_
,
ok
:=
p
.
spec
.
GetCode
(
hs
);
!
ok
{
return
nil
,
errorf
(
ErrHandshake
,
"unknown handshake message type: %T"
,
hs
)
}
var
rhs
interface
{}
errc
:=
make
(
chan
error
,
2
)
handle
:=
func
(
ctx
context
.
Context
,
msg
interface
{})
error
{
rhs
=
msg
...
...
@@ -412,6 +414,7 @@ func (p *Peer) Handshake(ctx context.Context, hs interface{}, verify func(interf
}()
for
i
:=
0
;
i
<
2
;
i
++
{
var
err
error
select
{
case
err
=
<-
errc
:
case
<-
ctx
.
Done
()
:
...
...
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