Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
af92856b
Commit
af92856b
authored
Feb 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
94746190
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
go/neo/xneo/nodetab.go
go/neo/xneo/nodetab.go
+16
-13
No files found.
go/neo/xneo/nodetab.go
View file @
af92856b
...
...
@@ -156,7 +156,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
proto
.
NodeInfo
)
*
PeerNode
{
node
:=
nt
.
Get
(
nodeInfo
.
NID
)
if
node
==
nil
{
node
=
&
PeerNode
{
l
ocalNode
:
nt
.
localNode
}
node
=
&
PeerNode
{
l
ink
:
&
_PeerLink
{
localNode
:
nt
.
localNode
}
}
nt
.
nodev
=
append
(
nt
.
nodev
,
node
)
}
...
...
@@ -224,9 +224,10 @@ func (nt *NodeTable) Clone() *NodeTable {
// See also: Link, ResetLink, Dial.
func
(
p
*
PeerNode
)
SetLink
(
link
*
neonet
.
NodeLink
)
{
// XXX see Link about locking - whether it is needed here or not
p
.
linkMu
.
Lock
()
p
.
link
=
link
p
.
linkMu
.
Unlock
()
l
:=
p
.
link
l
.
linkMu
.
Lock
()
l
.
link
=
link
l
.
linkMu
.
Unlock
()
}
// Link returns current link to peer node.
...
...
@@ -237,19 +238,21 @@ func (p *PeerNode) SetLink(link *neonet.NodeLink) {
func
(
p
*
PeerNode
)
Link
()
*
neonet
.
NodeLink
{
// XXX do we need lock here?
// XXX usages where Link is used (contrary to Dial) there is no need for lock
p
.
linkMu
.
Lock
()
link
:=
p
.
link
p
.
linkMu
.
Unlock
()
l
:=
p
.
link
l
.
linkMu
.
Lock
()
link
:=
l
.
link
l
.
linkMu
.
Unlock
()
return
link
}
// ResetLink closes link to peer and sets it to nil.
func
(
p
*
PeerNode
)
ResetLink
(
ctx
context
.
Context
)
{
p
.
linkMu
.
Lock
()
link
:=
p
.
link
p
.
link
=
nil
p
.
dialing
=
nil
// XXX what if dialing is in progress? -> cancel dialing with err?
p
.
linkMu
.
Unlock
()
l
:=
p
.
link
l
.
linkMu
.
Lock
()
link
:=
l
.
link
l
.
link
=
nil
l
.
dialing
=
nil
// XXX what if dialing is in progress? -> cancel dialing with err?
l
.
linkMu
.
Unlock
()
if
link
!=
nil
{
log
.
Infof
(
ctx
,
"%s: closing link"
,
link
)
...
...
@@ -263,7 +266,7 @@ func (p *PeerNode) ResetLink(ctx context.Context) {
// dial does low-level work to dial peer
// XXX p.* reading without lock - ok?
func
(
p
*
PeerNode
)
dial
(
ctx
context
.
Context
)
(
_
*
neonet
.
NodeLink
,
err
error
)
{
node
:=
p
.
localNode
node
:=
p
.
l
ink
.
l
ocalNode
s
:=
node
.
stateLog
.
ReadHead
()
// XXX better Dial gets the state from the caller? (as here it can be different from the context in which caller thinks it operates)
defer
task
.
Runningf
(
&
ctx
,
"dial %s"
,
p
.
NID
)(
&
err
)
...
...
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