Skip to content

Commit ce01509

Browse files
mtingersclaude
andcommitted
fix: allow --gc-max-idle 0 for immediate pruning
Validation rejected 0 despite the v1.8.1 changelog documenting it as valid ("prune immediately"). Changed check from <= 0 to < 0 and updated tests accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6c581e0 commit ce01509

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v1.13.2] - 2026-03-07
9+
10+
### Fixed
11+
12+
- **Config: `--gc-max-idle 0` rejected despite being documented as valid** — validation used `<= 0` instead of `< 0`, preventing the "prune immediately" setting documented in the v1.8.1 changelog from being configured via CLI or environment variable
13+
14+
[v1.13.2]: https://github.com/mtingers/dflockd/releases/tag/v1.13.2
15+
816
## [v1.13.1] - 2026-03-07
917

1018
### Fixed

‎internal/config/config.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ func (c *Config) validate() error {
237237
if c.MaxSubscriptions < 0 {
238238
return fmt.Errorf("--max-subscriptions must be >= 0 (got %d)", c.MaxSubscriptions)
239239
}
240-
if c.GCMaxIdleTime <= 0 {
241-
return fmt.Errorf("--gc-max-idle must be > 0 (got %s)", c.GCMaxIdleTime)
240+
if c.GCMaxIdleTime < 0 {
241+
return fmt.Errorf("--gc-max-idle must be >= 0 (got %s)", c.GCMaxIdleTime)
242242
}
243243
if (c.TLSCert != "") != (c.TLSKey != "") {
244244
return fmt.Errorf("both --tls-cert and --tls-key must be provided together")

‎internal/config/config_test.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestLoad_ValidationErrors(t *testing.T) {
3636
{"default-lease-ttl=0", []string{"--default-lease-ttl", "0"}, "default-lease-ttl"},
3737
{"lease-sweep-interval=0", []string{"--lease-sweep-interval", "0"}, "lease-sweep-interval"},
3838
{"gc-interval=0", []string{"--gc-interval", "0"}, "gc-interval"},
39-
{"gc-max-idle=0", []string{"--gc-max-idle", "0"}, "gc-max-idle"},
39+
{"gc-max-idle=-1", []string{"--gc-max-idle", "-1"}, "gc-max-idle"},
4040
{"read-timeout=0", []string{"--read-timeout", "0"}, "read-timeout"},
4141
{"port negative", []string{"--port", "-1"}, "port"},
4242
{"port too high", []string{"--port", "99999"}, "port"},
@@ -81,6 +81,12 @@ func TestLoad_ValidEdgeCases(t *testing.T) {
8181
if err != nil {
8282
t.Fatalf("max-waiters=0 should be valid: %v", err)
8383
}
84+
85+
// gc-max-idle=0 is valid (prune immediately)
86+
_, err = Load([]string{"--gc-max-idle", "0"})
87+
if err != nil {
88+
t.Fatalf("gc-max-idle=0 should be valid: %v", err)
89+
}
8490
}
8591

8692
func TestSecondsCeil(t *testing.T) {

0 commit comments

Comments
 (0)