Skip to content

Commit

Permalink
Force early cleanup of an instance when the instance list is re-slice…
Browse files Browse the repository at this point in the history
…d on Stop() & Restart() to prevent holding memory

Signed-off-by: Jeffrey Damick <[email protected]>
  • Loading branch information
Jeffrey Damick committed Jan 28, 2025
1 parent 8de9853 commit 02a5d37
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions caddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (i *Instance) Stop() error {
instancesMu.Lock()
for j, other := range instances {
if other == i {
instances[j] = nil
instances = append(instances[:j], instances[j+1:]...)
break
}
Expand Down Expand Up @@ -502,6 +503,7 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string][
instancesMu.Lock()
for i, otherInst := range instances {
if otherInst == inst {
instances[i] = nil
instances = append(instances[:i], instances[i+1:]...)
break
}
Expand Down

0 comments on commit 02a5d37

Please sign in to comment.