From fe2c9c2d0f007dde691cb81f02f69ebeac518ced Mon Sep 17 00:00:00 2001 From: rewby Date: Tue, 29 Aug 2023 00:08:07 +0200 Subject: [PATCH] Fix small bug in math if target is full. --- cmd/dispatcher/state.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/dispatcher/state.go b/cmd/dispatcher/state.go index a623471..1212282 100644 --- a/cmd/dispatcher/state.go +++ b/cmd/dispatcher/state.go @@ -188,8 +188,11 @@ func (state *State) UpdateThread() { inflightsSum := int64(0) inflightsCount := 0 for _, t := range targets { - inflightsSum = inflightsSum + t.Inflight - inflightsCount = inflightsCount + 1 + // Only count targets that can actually handle inbound in this calculation. + if t.FreeSpace > int64(t.Target.MinimumFreeSpace) { + inflightsSum = inflightsSum + t.Inflight + inflightsCount = inflightsCount + 1 + } } averageInflights := float64(inflightsSum) / float64(inflightsCount) log.Debugf("Average inflights: %v", averageInflights)