Skip to content

Hand graceful_shutdown()'s cancellation to the coroutines (#302) - #304

Merged
EdmondDantes merged 1 commit into
mainfrom
fix-302-graceful-shutdown-cancellation
Sep 17, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
fix-302-graceful-shutdown-cancellation

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

Closes #302.

graceful_shutdown($cancellationError) parsed the argument and then called ZEND_ASYNC_SHUTDOWN(), which takes nothing, so cancel_queued_coroutines() always built its own AsyncCancellation("Graceful shutdown").

start_graceful_shutdown_with(cancellation) carries the object into the scheduler; NULL keeps the default, and the API entry point start_graceful_shutdown() wraps it, so the ABI is unchanged. A shutdown already in progress keeps its own cancellation. The second cancellation pass in finally_shutdown() stays on the default.

Test: tests/edge_cases/015-graceful_shutdown_custom_cancellation.phpt, red without the change. Local run: ext/async/tests 1220 passed / 0 failed, fuzzy-tests/_generated 724 / 0.

The PHP function parsed $cancellationError and then called
ZEND_ASYNC_SHUTDOWN(), which takes nothing, so cancel_queued_coroutines()
always built its own AsyncCancellation("Graceful shutdown").

start_graceful_shutdown_with(cancellation) carries the object into the
scheduler; NULL keeps the default, and the API entry point
start_graceful_shutdown() wraps it, so the ABI is unchanged. The second
cancellation pass in finally_shutdown() stays on the default.

Test: tests/edge_cases/015-graceful_shutdown_custom_cancellation.phpt,
red without the change. ext/async/tests 1220 passed, fuzzy-tests/_generated
724 passed.
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@EdmondDantes
EdmondDantes merged commit e580c15 into main Sep 17, 2026
9 checks passed
@EdmondDantes
EdmondDantes deleted the fix-302-graceful-shutdown-cancellation branch September 17, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graceful_shutdown() ignores its $cancellationError argument

1 participant