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
16bc5743
Unverified
Commit
16bc5743
authored
May 20, 2021
by
Felix Lange
Committed by
GitHub
May 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/dnsdisc: fix crash when iterator closed before first call to Next (#22906)
parent
3e795881
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
client.go
p2p/dnsdisc/client.go
+6
-0
client_test.go
p2p/dnsdisc/client_test.go
+15
-0
No files found.
p2p/dnsdisc/client.go
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
()
...
...
p2p/dnsdisc/client_test.go
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
)
...
...
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