[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 12:05:18 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6c9506365fb: [Orc] Handle hangup messages in SimpleRemoteEPC (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111527/new/

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.378754.patch
Type: text/x-patch
Size: 2713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211011/aadab7bc/attachment.bin>


More information about the llvm-commits mailing list