[PATCH] D111527: [Orc] Handle hangup messages in SimpleRemoteEPC
Stefan Gränitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 11 01:33:17 PDT 2021
sgraenitz created this revision.
sgraenitz added a reviewer: lhames.
Herald added a subscriber: hiraditya.
sgraenitz requested review of this revision.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111527
Files:
llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
Index: llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
+++ llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp
@@ -121,8 +121,10 @@
return std::move(Err);
break;
case SimpleRemoteEPCOpcode::Hangup:
- return make_error<StringError>("Unexpected Hangup opcode",
- inconvertibleErrorCode());
+ T->disconnect();
+ if (auto Err = handleHangup(std::move(ArgBytes)))
+ return std::move(Err);
+ return EndSession;
case SimpleRemoteEPCOpcode::Result:
if (auto Err = handleResult(SeqNo, TagAddr, std::move(ArgBytes)))
return std::move(Err);
@@ -354,5 +356,19 @@
TagAddr.getValue(), ArgBytes);
}
+Error SimpleRemoteEPC::handleHangup(SimpleRemoteEPCArgBytesVector ArgBytes) {
+ using namespace llvm::orc::shared;
+ auto WFR = WrapperFunctionResult::copyFrom(ArgBytes.data(), ArgBytes.size());
+ if (const char *ErrMsg = WFR.getOutOfBandError())
+ return make_error<StringError>(ErrMsg, inconvertibleErrorCode());
+
+ detail::SPSSerializableError Info;
+ SPSInputBuffer IB(WFR.data(), WFR.size());
+ if (!SPSArgList<SPSError>::deserialize(IB, Info))
+ return make_error<StringError>("Could not deserialize hangup info",
+ inconvertibleErrorCode());
+ return fromSPSSerializable(std::move(Info));
+}
+
} // end namespace orc
} // end namespace llvm
Index: llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
+++ llvm/include/llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h
@@ -96,6 +96,7 @@
SimpleRemoteEPCArgBytesVector ArgBytes);
void handleCallWrapper(uint64_t RemoteSeqNo, ExecutorAddr TagAddr,
SimpleRemoteEPCArgBytesVector ArgBytes);
+ Error handleHangup(SimpleRemoteEPCArgBytesVector ArgBytes);
uint64_t getNextSeqNo() { return NextSeqNo++; }
void releaseSeqNo(uint64_t SeqNo) {}
Index: llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
+++ llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
@@ -94,7 +94,7 @@
/// Trigger disconnection from the transport. The implementation should
/// respond by calling handleDisconnect on the client once disconnection
- /// is complete.
+ /// is complete. May be called more than once and from different threads.
virtual void disconnect() = 0;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111527.378591.patch
Type: text/x-patch
Size: 2713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211011/24deeea4/attachment.bin>
More information about the llvm-commits
mailing list