fixup! fixup! ... and another all nighter.

This commit is contained in:
2025-10-22 16:16:54 +01:00
parent ae6c315824
commit 26b592f547
25 changed files with 11426 additions and 17 deletions
+8 -3
View File
@@ -134,12 +134,15 @@ func (tc *TokenCache) StartCleanup(interval time.Duration) {
return // Already running
}
// Create fresh stop channel for this cleanup session
tc.cleanupStop = make(chan bool, 1)
tc.cleanupTicker = time.NewTicker(interval)
tickerChan := tc.cleanupTicker.C // Capture channel before goroutine starts
go func() {
for {
select {
case <-tc.cleanupTicker.C:
case <-tickerChan:
tc.cleanupExpiredTokens()
case <-tc.cleanupStop:
return
@@ -157,9 +160,11 @@ func (tc *TokenCache) StopCleanup() {
if tc.cleanupTicker != nil {
tc.cleanupTicker.Stop()
select {
case tc.cleanupStop <- true: // Signal stop
default: // Channel might be full or goroutine already stopped
}
tc.cleanupTicker = nil
close(tc.cleanupStop)
tc.cleanupStop = make(chan bool)
tc.logger.Logf("Stopped token cache cleanup")
}
}