Skip to content

Commit 4cbebec

Browse files
authored
test: tolerate curl send errors when the listener closes during shutdown (#2724)
`tests/shutdown_test.sh` (added in #2645) failed on #2721 with `FAIL: PHP request failed with curl exit code 55` ([job](https://github.com/php/frankenphp/actions/runs/38898098911/job/116963348236)). The failure lines up with the last server log line, `servers shutting down; grace period initiated`, logged when Caddy closes its listeners after `shutdown_delay`. Closing a listening socket resets the connections still waiting in its accept queue. Depending on when the reset reaches curl, the request fails with 52 (empty reply), 56 (receive error) or 55 (send error). The test already treated 52 and 56 as `closing`, but not 55, which needs the reset to arrive between `connect()` and the first `send()`. Stressing the shutdown in a Linux container (40 restarts, 24 concurrent clients, ~36k requests against `main`) produced 29 × 52 and 30 × 56 at listener close and no other errors, so 55 is the same race with a narrower window. The server can't prevent it, so the test now accepts 55 too. The checks that matter are unchanged: requests served during `shutdown_delay`, in-flight requests drained, PHP shut down last. The patched script passed 10/10 runs in the same container.
1 parent 8667a12 commit 4cbebec

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎tests/shutdown_test.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ request() {
3838
case "$error" in
3939
0) printf '%s' "$status" ;;
4040
7) printf 'closed' ;;
41-
# An accepted connection can close while HTTP shutdown begins.
42-
52 | 56) printf 'closing' ;;
41+
# HTTP shutdown can drop a connection before curl sends (55), before any reply (52) or mid-read (56).
42+
52 | 55 | 56) printf 'closing' ;;
4343
*) printf 'error-%s' "$error" ;;
4444
esac
4545
}

0 commit comments

Comments
 (0)