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
c2b21e47
Commit
c2b21e47
authored
Dec 22, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
routing/mock test: kill leaked goroutine
parent
10bb354f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
routing/mock/mockrouting_test.go
routing/mock/mockrouting_test.go
+13
-0
No files found.
routing/mock/mockrouting_test.go
View file @
c2b21e47
...
...
@@ -96,10 +96,23 @@ func TestCanceledContext(t *testing.T) {
rs
:=
NewServer
()
k
:=
u
.
Key
(
"hello"
)
// avoid leaking goroutine, without using the context to signal
// (we want the goroutine to keep trying to publish on a
// cancelled context until we've tested it doesnt do anything.)
done
:=
make
(
chan
struct
{})
defer
func
()
{
done
<-
struct
{}{}
}()
t
.
Log
(
"async'ly announce infinite stream of providers for key"
)
i
:=
0
go
func
()
{
// infinite stream
for
{
select
{
case
<-
done
:
t
.
Log
(
"exiting async worker"
)
return
default
:
}
pi
:=
peer
.
PeerInfo
{
ID
:
peer
.
ID
(
i
)}
err
:=
rs
.
Client
(
pi
)
.
Provide
(
context
.
Background
(),
k
)
if
err
!=
nil
{
...
...
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