Skip to content

Simplify pending finish logic, NFC #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Sources/SwiftDriverExecution/MultiJobExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ class ExecuteJobRule: LLBuildRule {
let env = context.env.merging(job.extraEnvironment, uniquingKeysWith: { $1 })

let value: DriverBuildValue
var knownPId = Set<Int>()
var pendingFinish = false
var pid = 0
do {
let arguments: [String] = try resolver.resolveArgumentList(for: job,
Expand All @@ -525,8 +525,8 @@ class ExecuteJobRule: LLBuildRule {
// Inform the delegate.
context.delegateQueue.sync {
context.executorDelegate.jobStarted(job: job, arguments: arguments, pid: pid)
knownPId.insert(pid)
}
pendingFinish = true

let result = try process.waitUntilExit()
let success = result.exitStatus == .terminated(code: EXIT_SUCCESS)
Expand All @@ -552,6 +552,7 @@ class ExecuteJobRule: LLBuildRule {
context.delegateQueue.sync {
context.executorDelegate.jobFinished(job: job, result: result, pid: pid)
}
pendingFinish = false
context.cancelBuildIfNeeded(result)
if !context.isBuildCancelled {
try context.addRuleBeyondMandatoryCompiles(finishedJob: job, result: result)
Expand All @@ -563,7 +564,7 @@ class ExecuteJobRule: LLBuildRule {
}
// Only inform finished job if the job has been started, otherwise the build
// system may complain about malformed output
if (knownPId.contains(pid)) {
if (pendingFinish) {
context.delegateQueue.sync {
let result = ProcessResult(
arguments: [],
Expand Down