Skip to content

Commit a6c9506

Browse files
[Orc] Handle hangup messages in SimpleRemoteEPC
On the controller-side, handle `Hangup` messages from the executor. The executor passed `Error::success()` or a failure message as payload. Hangups cause an immediate disconnect of the transport layer. The disconnect function may be called later again and so implementations should be prepared. `FDSimpleRemoteEPCTransport::disconnect()` already has a flag to check that: https://github.com/llvm/llvm-project/blob/cd1bd95d8707371da0e4f75cd01669c427466931/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp#L112 Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D111527
1 parent ec2d0de commit a6c9506

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class SimpleRemoteEPCTransport {
9494

9595
/// Trigger disconnection from the transport. The implementation should
9696
/// respond by calling handleDisconnect on the client once disconnection
97-
/// is complete.
97+
/// is complete. May be called more than once and from different threads.
9898
virtual void disconnect() = 0;
9999
};
100100

llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class SimpleRemoteEPC : public ExecutorProcessControl,
9696
SimpleRemoteEPCArgBytesVector ArgBytes);
9797
void handleCallWrapper(uint64_t RemoteSeqNo, ExecutorAddr TagAddr,
9898
SimpleRemoteEPCArgBytesVector ArgBytes);
99+
Error handleHangup(SimpleRemoteEPCArgBytesVector ArgBytes);
99100

100101
uint64_t getNextSeqNo() { return NextSeqNo++; }
101102
void releaseSeqNo(uint64_t SeqNo) {}

llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ SimpleRemoteEPC::handleMessage(SimpleRemoteEPCOpcode OpC, uint64_t SeqNo,
121121
return std::move(Err);
122122
break;
123123
case SimpleRemoteEPCOpcode::Hangup:
124-
return make_error<StringError>("Unexpected Hangup opcode",
125-
inconvertibleErrorCode());
124+
T->disconnect();
125+
if (auto Err = handleHangup(std::move(ArgBytes)))
126+
return std::move(Err);
127+
return EndSession;
126128
case SimpleRemoteEPCOpcode::Result:
127129
if (auto Err = handleResult(SeqNo, TagAddr, std::move(ArgBytes)))
128130
return std::move(Err);
@@ -354,5 +356,19 @@ void SimpleRemoteEPC::handleCallWrapper(
354356
TagAddr.getValue(), ArgBytes);
355357
}
356358

359+
Error SimpleRemoteEPC::handleHangup(SimpleRemoteEPCArgBytesVector ArgBytes) {
360+
using namespace llvm::orc::shared;
361+
auto WFR = WrapperFunctionResult::copyFrom(ArgBytes.data(), ArgBytes.size());
362+
if (const char *ErrMsg = WFR.getOutOfBandError())
363+
return make_error<StringError>(ErrMsg, inconvertibleErrorCode());
364+
365+
detail::SPSSerializableError Info;
366+
SPSInputBuffer IB(WFR.data(), WFR.size());
367+
if (!SPSArgList<SPSError>::deserialize(IB, Info))
368+
return make_error<StringError>("Could not deserialize hangup info",
369+
inconvertibleErrorCode());
370+
return fromSPSSerializable(std::move(Info));
371+
}
372+
357373
} // end namespace orc
358374
} // end namespace llvm

0 commit comments

Comments
 (0)