Skip to content

Commit d349229

Browse files
committed
fixed a bug that would result in the mutex being locked after the cleanup job had found a secret that was expired
1 parent 241e4ac commit d349229

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func init() {
5050

5151
func secretCleaner() {
5252
for {
53-
time.Sleep(5 * time.Minute)
53+
time.Sleep(5 * time.Second)
5454
secretStore.Lock.RLock()
5555
for k, v := range secretStore.Data {
5656
s, err := Decrypt(v, k)
@@ -61,7 +61,9 @@ func secretCleaner() {
6161
isNotExpired := s.Expires.UTC().After(time.Now().UTC())
6262
if !isNotExpired {
6363
log.Debug().Msg("Found expired secret, deleting...")
64+
secretStore.Lock.RUnlock()
6465
secretStore.Delete(k)
66+
secretStore.Lock.RLock()
6567
}
6668
}
6769
secretStore.Lock.RUnlock()

0 commit comments

Comments
 (0)