Repository navigation
Check for an abort before each start in the dispatcher - #121
Merged
Merged
Conversation
…ograms a list is quoted for
The dispatcher checks for an abort once per pass, and its start loop read only the token, which that check cancels. So a Ctrl+C landing while the loop was starting programs, or a -JobStarter that requested an abort, still filled every free slot on that pass. The start loop now also reads the abort flag before each job, ahead of the shared budget's Wait(0) so no slot is taken for a job that won't start. Harness section O covers a -JobStarter that requests an abort, with a plain limit and with a shared budget.
The test that kills a live tree listed beside a disposed process counted leftover pings right after Stop-PkProcessTree returned. Ending a Job Object returns before Windows has finished tearing its processes down, so on a CI runner the ping was still listed once. It now waits up to 5 seconds for it to go, as the other kill tests do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #120, merge after it.
What was wrong: since #114 the dispatcher checks for an abort at the top of each pass and after
-PollCallback. Its start loop still read only the token, which that check cancels. So an abort that arrived while the loop was starting programs went unseen until the next pass, and every free slot on the current pass was still filled. That covers a Ctrl+C landing mid-loop and a-JobStartercallingRequest-PkAbort. The extra programs were drained as usual, so nothing leaked, but they shouldn't have started.What changed: the start loop's condition also reads
[PkConsoleCtrl]::AbortRequestedbefore each job, as the runspace engine's launch loop has since #114. That's a field read per job, not a function call. It comes before the shared budget'sWait(0), so an abort never takes a slot for a job that won't start.How it was tested: harness section O runs a
-JobStarterthat requests an abort on its first call, with 6 jobs and-MaxConcurrent 3. It runs once with a plain limit and once with a sharedSemaphoreSlimbudget of 3, checking that no slot is left taken.Before the fix (Windows PowerShell 5.1 and PowerShell 7, the same on both):
After:
started 1 of 6, and3 of 3 slots free after.Full harness: all 776 assertions pass on Windows PowerShell 5.1 and on PowerShell 7.