From 2374ffe161439b02a8e7f23b793461b39a635bf8 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 20 Oct 2026 14:11:21 +0800 Subject: [PATCH] gateway: a request whose agent goes while it waits for room ends its wait before giving its place back TestMaxRPMAgentGoneWhileWaiting went red on ubuntu CI at 588f87a12 ("1 still waiting for room after the agent went"). On a cancel, wait gave the place back first and stopped its timer only in a defer after, so the test could see the place back while the wait was still registered. The wait now stops its timer, then gives the place back. Run: - Injected a 100ms pause after giveBack: the old order is red 3 of 3, the new order green 3 of 3. - go test -race -run TestMaxRPM -count=10 ./internal/gateway: ok. - go test ./... -count=1 -timeout 45m (load ~200): every package ok except internal/gui, where TestMainWindowCorners and TestMainWindowRightToLeft were killed at their deadline (#1936, #2645). Run alone: ok in 36s. - gofmt -l clean. --- internal/gateway/rpm.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/gateway/rpm.go b/internal/gateway/rpm.go index 4bf0eb43a..749387081 100644 --- a/internal/gateway/rpm.go +++ b/internal/gateway/rpm.go @@ -177,6 +177,9 @@ func (l *rpms) wait(ctx context.Context, who string, limit int, longest time.Dur case <-c: return d, nil case <-ctx.Done(): + // the wait ends before its place is given back, so once the place + // is back nothing is left to send it + stop() l.giveBack(who, at) return rpmNow().Sub(now), ctx.Err() }