Skip to content

Commit 1408ec4

Browse files
committed
Added global ticker to locker.go
Signed-off-by: Effi-S <effi.szt@gmail.com>
1 parent 5c8aafc commit 1408ec4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • token/services/selector/simple/inmemory

token/services/selector/simple/inmemory/locker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ func (d *locker) lockedCount() int {
381381

382382
func (d *locker) scan(ctx context.Context) {
383383
defer close(d.scanDone)
384+
385+
ticker := time.NewTicker(d.sleepTimeout)
386+
defer ticker.Stop()
384387
for {
385388
// Check for shutdown before starting a new scan cycle.
386389
select {
@@ -462,7 +465,7 @@ func (d *locker) scan(ctx context.Context) {
462465
for {
463466
logger.DebugfContext(ctx, "token collector: sleep for some time...")
464467
select {
465-
case <-time.After(d.sleepTimeout):
468+
case <-ticker.C:
466469
case <-ctx.Done():
467470
logger.Debugf("token collector: stopping during sleep")
468471

0 commit comments

Comments
 (0)