[Distributed] Don't hang, but throw when target accessor not found

This commit is contained in:
Konrad `ktoso` Malawski
2022-07-28 17:30:20 +09:00
parent c2f5d57da9
commit fbc829fbbd
3 changed files with 93 additions and 2 deletions

View File

@@ -109,6 +109,11 @@ static void swift_distributed_execute_target_resume(
return resumeInParent(parentCtx, error);
}
SWIFT_CC(swift)
SWIFT_EXPORT_FROM(swiftDistributed)
SwiftError* swift_distributed_makeDistributedTargetAccessorNotFoundError(
const char *targetNameStart, size_t targetNameLength);
SWIFT_CC(swiftasync)
void swift_distributed_execute_target(
SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
@@ -124,8 +129,12 @@ void swift_distributed_execute_target(
void **decoderWitnessTable) {
auto *accessor = findDistributedAccessor(targetNameStart, targetNameLength);
if (!accessor) {
assert(false && "no distributed accessor");
return; // FIXME(distributed): return -1 here so the lib can fail the call
SwiftError *error =
swift_distributed_makeDistributedTargetAccessorNotFoundError(targetNameStart, targetNameLength);
auto resumeInParent =
reinterpret_cast<TargetExecutorSignature::ContinuationType *>(
callerContext->ResumeParent);
return resumeInParent(callerContext, error);
}
auto *asyncFnPtr = reinterpret_cast<