Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
0bd63633
Commit
0bd63633
authored
10 years ago
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dht/kbucket: race condition fix
parent
87458f6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
routing/kbucket/bucket.go
routing/kbucket/bucket.go
+11
-4
routing/kbucket/table.go
routing/kbucket/table.go
+3
-3
No files found.
routing/kbucket/bucket.go
View file @
0bd63633
...
...
@@ -19,6 +19,17 @@ func newBucket() *Bucket {
return
b
}
func
(
b
*
Bucket
)
Peers
()
[]
peer
.
ID
{
b
.
lk
.
RLock
()
defer
b
.
lk
.
RUnlock
()
ps
:=
make
([]
peer
.
ID
,
0
,
b
.
list
.
Len
())
for
e
:=
b
.
list
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
id
:=
e
.
Value
.
(
peer
.
ID
)
ps
=
append
(
ps
,
id
)
}
return
ps
}
func
(
b
*
Bucket
)
find
(
id
peer
.
ID
)
*
list
.
Element
{
b
.
lk
.
RLock
()
defer
b
.
lk
.
RUnlock
()
...
...
@@ -81,7 +92,3 @@ func (b *Bucket) Split(cpl int, target ID) *Bucket {
}
return
newbuck
}
func
(
b
*
Bucket
)
getIter
()
*
list
.
Element
{
return
b
.
list
.
Front
()
}
This diff is collapsed.
Click to expand it.
routing/kbucket/table.go
View file @
0bd63633
...
...
@@ -176,11 +176,11 @@ func (rt *RoutingTable) Size() int {
// NOTE: This is potentially unsafe... use at your own risk
func
(
rt
*
RoutingTable
)
ListPeers
()
[]
peer
.
ID
{
var
peers
[]
peer
.
ID
rt
.
tabLock
.
RLock
()
for
_
,
buck
:=
range
rt
.
Buckets
{
for
e
:=
buck
.
getIter
();
e
!=
nil
;
e
=
e
.
Next
()
{
peers
=
append
(
peers
,
e
.
Value
.
(
peer
.
ID
))
}
peers
=
append
(
peers
,
buck
.
Peers
()
...
)
}
rt
.
tabLock
.
RUnlock
()
return
peers
}
...
...
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