Remove idle upstream host semaphores and delete a variant's .meta file with it (closes #87) #171

Merged
clawbot merged 3 commits from issue-87-hostsems-meta into next 2026-10-04 07:11:32 +02:00
Showing only changes of commit 4d30d17e44 - Show all commits
@@ -153,9 +153,11 @@ func TestFetchRemovesIdleHostSemaphores(t *testing.T) {
}
// TestFetchRemovesHostSemaphoreWhenNoConnection checks that a fetch that
// ends without a connection leaves no semaphore behind, both when it is
// refused after waiting for a connection shared by all hosts and when its
// context ends while it waits for its host's slot.
// ends without a connection leaves no semaphore behind: when it is refused
// after waiting for a connection shared by all hosts, when its context ends
// while it waits for its host's slot, and when its context ends while it
// waits for a connection shared by all hosts, long before the 10 second
// wait timeout.
func TestFetchRemovesHostSemaphoreWhenNoConnection(t *testing.T) {
t.Parallel()
@@ -188,6 +190,18 @@ func TestFetchRemovesHostSemaphoreWhenNoConnection(t *testing.T) {
"want context.DeadlineExceeded", err)
}
// Back to the 10 second wait, so the next fetch's context ends first.
f.connectionWaitTimeout = ConnectionWaitTimeout
ctx, cancel = context.WithTimeout(t.Context(), 100*time.Millisecond)
defer cancel()
_, err = f.Fetch(ctx, imageURLOnPort(83))
if !errors.Is(err, context.DeadlineExceeded) {
t.Fatalf("Fetch() from a host with nothing open: error = %v, "+
"want context.DeadlineExceeded", err)
}
err = open.Content.Close()
if err != nil {
t.Fatalf("close first body: %v", err)