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
a9614c3c
Unverified
Commit
a9614c3c
authored
Feb 12, 2020
by
Boqin Qin
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event, p2p/simulations/adapters: fix rare goroutine leaks (#20657)
Co-authored-by:
Felix Lange
<
fjl@twurst.com
>
parent
46c4b699
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
subscription.go
event/subscription.go
+8
-9
subscription_test.go
event/subscription_test.go
+1
-1
exec.go
p2p/simulations/adapters/exec.go
+1
-1
No files found.
event/subscription.go
View file @
a9614c3c
...
...
@@ -145,7 +145,6 @@ func (s *resubscribeSub) loop() {
func
(
s
*
resubscribeSub
)
subscribe
()
Subscription
{
subscribed
:=
make
(
chan
error
)
var
sub
Subscription
retry
:
for
{
s
.
lastTry
=
mclock
.
Now
()
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
...
...
@@ -157,19 +156,19 @@ retry:
select
{
case
err
:=
<-
subscribed
:
cancel
()
if
err
!=
nil
{
// Subscribing failed, wait before launching the next try.
if
s
.
backoffWait
()
{
return
nil
if
err
==
nil
{
if
sub
==
nil
{
panic
(
"event: ResubscribeFunc returned nil subscription and no error"
)
}
continue
retry
return
sub
}
if
sub
==
nil
{
panic
(
"event: ResubscribeFunc returned nil subscription and no error"
)
// Subscribing failed, wait before launching the next try.
if
s
.
backoffWait
()
{
return
nil
// unsubscribed during wait
}
return
sub
case
<-
s
.
unsub
:
cancel
()
<-
subscribed
// avoid leaking the s.fn goroutine.
return
nil
}
}
...
...
event/subscription_test.go
View file @
a9614c3c
...
...
@@ -102,7 +102,7 @@ func TestResubscribe(t *testing.T) {
func
TestResubscribeAbort
(
t
*
testing
.
T
)
{
t
.
Parallel
()
done
:=
make
(
chan
error
)
done
:=
make
(
chan
error
,
1
)
sub
:=
Resubscribe
(
0
,
func
(
ctx
context
.
Context
)
(
Subscription
,
error
)
{
select
{
case
<-
ctx
.
Done
()
:
...
...
p2p/simulations/adapters/exec.go
View file @
a9614c3c
...
...
@@ -287,7 +287,7 @@ func (n *ExecNode) Stop() error {
if
err
:=
n
.
Cmd
.
Process
.
Signal
(
syscall
.
SIGTERM
);
err
!=
nil
{
return
n
.
Cmd
.
Process
.
Kill
()
}
waitErr
:=
make
(
chan
error
)
waitErr
:=
make
(
chan
error
,
1
)
go
func
()
{
waitErr
<-
n
.
Cmd
.
Wait
()
}()
...
...
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