good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
406e74e2
Commit
406e74e2
authored
Apr 22, 2015
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
whisper: fix a small data race duirng peer connection
parent
70ded4cb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
whisper/peer.go
+2
-6
2 additions, 6 deletions
whisper/peer.go
whisper/whisper.go
+10
-8
10 additions, 8 deletions
whisper/whisper.go
with
12 additions
and
14 deletions
whisper/peer.go
+
2
−
6
View file @
406e74e2
...
@@ -23,18 +23,14 @@ type peer struct {
...
@@ -23,18 +23,14 @@ type peer struct {
// newPeer creates and initializes a new whisper peer connection, returning either
// newPeer creates and initializes a new whisper peer connection, returning either
// the newly constructed link or a failure reason.
// the newly constructed link or a failure reason.
func
newPeer
(
host
*
Whisper
,
remote
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
(
*
peer
,
error
)
{
func
newPeer
(
host
*
Whisper
,
remote
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
*
peer
{
p
:=
&
peer
{
return
&
peer
{
host
:
host
,
host
:
host
,
peer
:
remote
,
peer
:
remote
,
ws
:
rw
,
ws
:
rw
,
known
:
set
.
New
(),
known
:
set
.
New
(),
quit
:
make
(
chan
struct
{}),
quit
:
make
(
chan
struct
{}),
}
}
if
err
:=
p
.
handshake
();
err
!=
nil
{
return
nil
,
err
}
return
p
,
nil
}
}
// start initiates the peer updater, periodically broadcasting the whisper packets
// start initiates the peer updater, periodically broadcasting the whisper packets
...
...
This diff is collapsed.
Click to expand it.
whisper/whisper.go
+
10
−
8
View file @
406e74e2
...
@@ -168,15 +168,9 @@ func (self *Whisper) Messages(id int) []*Message {
...
@@ -168,15 +168,9 @@ func (self *Whisper) Messages(id int) []*Message {
// handlePeer is called by the underlying P2P layer when the whisper sub-protocol
// handlePeer is called by the underlying P2P layer when the whisper sub-protocol
// connection is negotiated.
// connection is negotiated.
func
(
self
*
Whisper
)
handlePeer
(
peer
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
error
{
func
(
self
*
Whisper
)
handlePeer
(
peer
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
error
{
// Create, initialize and start the whisper peer
// Create the new peer and start tracking it
whisperPeer
,
err
:=
newPeer
(
self
,
peer
,
rw
)
whisperPeer
:=
newPeer
(
self
,
peer
,
rw
)
if
err
!=
nil
{
return
err
}
whisperPeer
.
start
()
defer
whisperPeer
.
stop
()
// Start tracking the active peer
self
.
peerMu
.
Lock
()
self
.
peerMu
.
Lock
()
self
.
peers
[
whisperPeer
]
=
struct
{}{}
self
.
peers
[
whisperPeer
]
=
struct
{}{}
self
.
peerMu
.
Unlock
()
self
.
peerMu
.
Unlock
()
...
@@ -186,6 +180,14 @@ func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
...
@@ -186,6 +180,14 @@ func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
delete
(
self
.
peers
,
whisperPeer
)
delete
(
self
.
peers
,
whisperPeer
)
self
.
peerMu
.
Unlock
()
self
.
peerMu
.
Unlock
()
}()
}()
// Run the peer handshake and state updates
if
err
:=
whisperPeer
.
handshake
();
err
!=
nil
{
return
err
}
whisperPeer
.
start
()
defer
whisperPeer
.
stop
()
// Read and process inbound messages directly to merge into client-global state
// Read and process inbound messages directly to merge into client-global state
for
{
for
{
// Fetch the next packet and decode the contained envelopes
// Fetch the next packet and decode the contained envelopes
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment