Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
Fixed route-sync ticker-based memory leak
Browse files Browse the repository at this point in the history
Issue #140.

[#153211365]

Signed-off-by: Travis Hall <thall@vmware.com>
  • Loading branch information
bsnchan authored and tvs committed Dec 5, 2017
1 parent a98f0b9 commit 603fdc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/route-sync/pooler/pooler.go
Expand Up @@ -52,15 +52,17 @@ func (tb *timeBased) tick(src route.Source, router route.Router) {
}

func (tb *timeBased) Run(ctx context.Context, src route.Source, router route.Router) {
timer := time.Tick(1)
ticker := time.NewTicker(tb.interval)
defer ticker.Stop()

tb.tick(src, router)

for {
select {
case <-ctx.Done():
return
case <-timer:
case <-ticker.C:
tb.tick(src, router)
timer = time.Tick(tb.interval)
}
}
}
2 changes: 1 addition & 1 deletion src/route-sync/pooler/pooler_test.go
Expand Up @@ -29,7 +29,7 @@ var _ = Describe("Time-based Pooler", func() {

BeforeEach(func() {
logger = lagertest.NewTestLogger("")
pool = pooler.ByTime(time.Duration(0), logger)
pool = pooler.ByTime(time.Duration(1), logger)
src = &routefakes.FakeSource{}

tcpRoutes = []*route.TCP{
Expand Down

0 comments on commit 603fdc1

Please sign in to comment.