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
16bc5743
Unverified
Commit
16bc5743
authored
May 20, 2021
by
Felix Lange
Committed by
GitHub
May 20, 2021
Browse files
Options
Downloads
Patches
Plain Diff
p2p/dnsdisc: fix crash when iterator closed before first call to Next (#22906)
parent
3e795881
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
p2p/dnsdisc/client.go
+6
-0
6 additions, 0 deletions
p2p/dnsdisc/client.go
p2p/dnsdisc/client_test.go
+15
-0
15 additions, 0 deletions
p2p/dnsdisc/client_test.go
with
21 additions
and
0 deletions
p2p/dnsdisc/client.go
+
6
−
0
View file @
16bc5743
...
...
@@ -298,6 +298,12 @@ func (it *randomIterator) pickTree() *clientTree {
it
.
mu
.
Lock
()
defer
it
.
mu
.
Unlock
()
// First check if iterator was closed.
// Need to do this here to avoid nil map access in rebuildTrees.
if
it
.
trees
==
nil
{
return
nil
}
// Rebuild the trees map if any links have changed.
if
it
.
lc
.
changed
{
it
.
rebuildTrees
()
...
...
This diff is collapsed.
Click to expand it.
p2p/dnsdisc/client_test.go
+
15
−
0
View file @
16bc5743
...
...
@@ -115,6 +115,21 @@ func TestIterator(t *testing.T) {
checkIterator
(
t
,
it
,
nodes
)
}
func
TestIteratorCloseWithoutNext
(
t
*
testing
.
T
)
{
tree1
,
url1
:=
makeTestTree
(
"t1"
,
nil
,
nil
)
c
:=
NewClient
(
Config
{
Resolver
:
newMapResolver
(
tree1
.
ToTXT
(
"t1"
))})
it
,
err
:=
c
.
NewIterator
(
url1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
it
.
Close
()
ok
:=
it
.
Next
()
if
ok
{
t
.
Fatal
(
"Next returned true after Close"
)
}
}
// This test checks if closing randomIterator races.
func
TestIteratorClose
(
t
*
testing
.
T
)
{
nodes
:=
testNodes
(
nodesSeed1
,
500
)
...
...
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