Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
96781416
Commit
96781416
authored
Mar 04, 2022
by
Chris O'Haver
Committed by
GitHub
Mar 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use tickers instead of time.After to avoid memory leak (#5220)
Signed-off-by:
Chris O'Haver
<
cohaver@infoblox.com
>
parent
d40d2242
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
13 deletions
+31
-13
plugin/azure/azure.go
plugin/azure/azure.go
+5
-1
plugin/clouddns/clouddns.go
plugin/clouddns/clouddns.go
+5
-1
plugin/dnstap/io.go
plugin/dnstap/io.go
+4
-3
plugin/kubernetes/kubernetes.go
plugin/kubernetes/kubernetes.go
+13
-7
plugin/route53/route53.go
plugin/route53/route53.go
+4
-1
No files found.
plugin/azure/azure.go
View file @
96781416
...
...
@@ -84,12 +84,16 @@ func (h *Azure) Run(ctx context.Context) error {
return
err
}
go
func
()
{
delay
:=
1
*
time
.
Minute
timer
:=
time
.
NewTimer
(
delay
)
defer
timer
.
Stop
()
for
{
timer
.
Reset
(
delay
)
select
{
case
<-
ctx
.
Done
()
:
log
.
Debugf
(
"Breaking out of Azure update loop for %v: %v"
,
h
.
zoneNames
,
ctx
.
Err
())
return
case
<-
time
.
After
(
1
*
time
.
Minute
)
:
case
<-
time
r
.
C
:
if
err
:=
h
.
updateZones
(
ctx
);
err
!=
nil
&&
ctx
.
Err
()
==
nil
{
log
.
Errorf
(
"Failed to update zones %v: %v"
,
h
.
zoneNames
,
err
)
}
...
...
plugin/clouddns/clouddns.go
View file @
96781416
...
...
@@ -82,12 +82,16 @@ func (h *CloudDNS) Run(ctx context.Context) error {
return
err
}
go
func
()
{
delay
:=
1
*
time
.
Minute
timer
:=
time
.
NewTimer
(
delay
)
defer
timer
.
Stop
()
for
{
timer
.
Reset
(
delay
)
select
{
case
<-
ctx
.
Done
()
:
log
.
Debugf
(
"Breaking out of CloudDNS update loop for %v: %v"
,
h
.
zoneNames
,
ctx
.
Err
())
return
case
<-
time
.
After
(
1
*
time
.
Minute
)
:
case
<-
time
r
.
C
:
if
err
:=
h
.
updateZones
(
ctx
);
err
!=
nil
&&
ctx
.
Err
()
==
nil
/* Don't log error if ctx expired. */
{
log
.
Errorf
(
"Failed to update zones %v: %v"
,
h
.
zoneNames
,
err
)
}
...
...
plugin/dnstap/io.go
View file @
96781416
...
...
@@ -92,8 +92,10 @@ func (d *dio) write(payload *tap.Dnstap) error {
}
func
(
d
*
dio
)
serve
()
{
timeout
:=
time
.
After
(
d
.
flushTimeout
)
timeout
:=
time
.
NewTimer
(
d
.
flushTimeout
)
defer
timeout
.
Stop
()
for
{
timeout
.
Reset
(
d
.
flushTimeout
)
select
{
case
<-
d
.
quit
:
if
d
.
enc
==
nil
{
...
...
@@ -106,7 +108,7 @@ func (d *dio) serve() {
if
err
:=
d
.
write
(
&
payload
);
err
!=
nil
{
d
.
dial
()
}
case
<-
timeout
:
case
<-
timeout
.
C
:
if
dropped
:=
atomic
.
SwapUint32
(
&
d
.
dropped
,
0
);
dropped
>
0
{
log
.
Warningf
(
"Dropped dnstap messages: %d"
,
dropped
)
}
...
...
@@ -115,7 +117,6 @@ func (d *dio) serve() {
}
else
{
d
.
enc
.
flush
()
}
timeout
=
time
.
After
(
d
.
flushTimeout
)
}
}
}
plugin/kubernetes/kubernetes.go
View file @
96781416
...
...
@@ -275,19 +275,25 @@ func (k *Kubernetes) InitKubeCache(ctx context.Context) (onStart func() error, o
k
.
APIConn
.
Run
()
}()
timeout
:=
time
.
After
(
5
*
time
.
Second
)
logWaiting
:=
time
.
After
(
500
*
time
.
Millisecond
)
ticker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
defer
ticker
.
Stop
()
timeout
:=
5
*
time
.
Second
timeoutTicker
:=
time
.
NewTicker
(
timeout
)
defer
timeoutTicker
.
Stop
()
logDelay
:=
500
*
time
.
Millisecond
logTicker
:=
time
.
NewTicker
(
logDelay
)
defer
logTicker
.
Stop
()
checkSyncTicker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
defer
checkSyncTicker
.
Stop
()
for
{
timeoutTicker
.
Reset
(
timeout
)
logTicker
.
Reset
(
logDelay
)
select
{
case
<-
t
icker
.
C
:
case
<-
checkSyncT
icker
.
C
:
if
k
.
APIConn
.
HasSynced
()
{
return
nil
}
case
<-
log
Waiting
:
case
<-
log
Ticker
.
C
:
log
.
Info
(
"waiting for Kubernetes API before starting server"
)
case
<-
timeout
:
case
<-
timeout
Ticker
.
C
:
log
.
Warning
(
"starting server with unsynced Kubernetes API"
)
return
nil
}
...
...
plugin/route53/route53.go
View file @
96781416
...
...
@@ -84,12 +84,15 @@ func (h *Route53) Run(ctx context.Context) error {
return
err
}
go
func
()
{
timer
:=
time
.
NewTimer
(
h
.
refresh
)
defer
timer
.
Stop
()
for
{
timer
.
Reset
(
h
.
refresh
)
select
{
case
<-
ctx
.
Done
()
:
log
.
Debugf
(
"Breaking out of Route53 update loop for %v: %v"
,
h
.
zoneNames
,
ctx
.
Err
())
return
case
<-
time
.
After
(
h
.
refresh
)
:
case
<-
time
r
.
C
:
if
err
:=
h
.
updateZones
(
ctx
);
err
!=
nil
&&
ctx
.
Err
()
==
nil
/* Don't log error if ctx expired. */
{
log
.
Errorf
(
"Failed to update zones %v: %v"
,
h
.
zoneNames
,
err
)
}
...
...
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