Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
eab22ff9
Commit
eab22ff9
authored
Nov 15, 2015
by
Prashanth Balasubramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timer leak in wait.Poll
parent
961a02a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
wait.go
pkg/util/wait/wait.go
+6
-1
wait_test.go
pkg/util/wait/wait_test.go
+15
-0
No files found.
pkg/util/wait/wait.go
View file @
eab22ff9
...
...
@@ -132,7 +132,12 @@ func poller(interval, timeout time.Duration) WaitFunc {
for
{
select
{
case
<-
tick
.
C
:
ch
<-
struct
{}{}
// If the consumer isn't ready for this signal drop it and
// check the other channels.
select
{
case
ch
<-
struct
{}{}
:
default
:
}
case
<-
after
:
return
case
<-
done
:
...
...
pkg/util/wait/wait_test.go
View file @
eab22ff9
...
...
@@ -257,3 +257,18 @@ func TestWaitFor(t *testing.T) {
}
}
}
func
TestWaitForWithDelay
(
t
*
testing
.
T
)
{
done
:=
make
(
chan
struct
{})
defer
close
(
done
)
WaitFor
(
poller
(
time
.
Millisecond
,
util
.
ForeverTestTimeout
),
func
()
(
bool
,
error
)
{
time
.
Sleep
(
10
*
time
.
Millisecond
)
return
true
,
nil
},
done
)
// If polling goroutine doesn't see the done signal it will leak timers.
select
{
case
done
<-
struct
{}{}
:
case
<-
time
.
After
(
util
.
ForeverTestTimeout
)
:
t
.
Errorf
(
"expected an ack of the done signal."
)
}
}
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