Skip to content

Commit 67c20cd

Browse files
committed
fix some edge cases
1 parent c5c61cc commit 67c20cd

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

internal/state/lock.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ func (fl *FileLock) Lock() error {
4848
if info, statErr := os.Stat(fl.lockPath); statErr == nil {
4949
if time.Since(info.ModTime()) > 10*time.Second {
5050
// Lock file is stale, remove it and try again
51-
os.Remove(fl.lockPath)
51+
err = os.Remove(fl.lockPath)
52+
if err != nil {
53+
return fmt.Errorf("unable to remove lock: %v", err)
54+
}
55+
continue
5256
}
5357
}
5458
}

internal/state/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func ReconcileState(fileState State, rateCache, botCache, verifiedCache *lru.Cac
151151

152152
// Reconcile rate cache
153153
for k, fileEntry := range fileState.Rate {
154-
if fileEntry.Expiration > 0 && fileEntry.Expiration < now {
154+
if fileEntry.Expiration > 0 && fileEntry.Expiration <= now {
155155
continue // Skip expired entries
156156
}
157157

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
const (
2828
// StateSaveInterval is how often the persistent state file is written to disk
29-
StateSaveInterval = 5 * time.Second
29+
StateSaveInterval = 10 * time.Second
3030
// StateSaveJitter is the maximum random jitter added to save interval to prevent thundering herd
3131
StateSaveJitter = 2 * time.Second
3232
)

0 commit comments

Comments
 (0)