Skip to content

Commit

Permalink
fixed a bug that would result in the mutex being locked after the cle…
Browse files Browse the repository at this point in the history
…anup job had found a secret that was expired
  • Loading branch information
Gaardsholt committed Oct 12, 2021
1 parent 241e4ac commit d349229
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func init() {

func secretCleaner() {
for {
time.Sleep(5 * time.Minute)
time.Sleep(5 * time.Second)
secretStore.Lock.RLock()
for k, v := range secretStore.Data {
s, err := Decrypt(v, k)
Expand All @@ -61,7 +61,9 @@ func secretCleaner() {
isNotExpired := s.Expires.UTC().After(time.Now().UTC())
if !isNotExpired {
log.Debug().Msg("Found expired secret, deleting...")
secretStore.Lock.RUnlock()
secretStore.Delete(k)
secretStore.Lock.RLock()
}
}
secretStore.Lock.RUnlock()
Expand Down

0 comments on commit d349229

Please sign in to comment.