]> granicus.if.org Git - llvm/commitdiff
[Orc][RPC] Unlock message send/receive locks on failure.
authorLang Hames <lhames@gmail.com>
Sat, 28 Jan 2017 10:19:47 +0000 (10:19 +0000)
committerLang Hames <lhames@gmail.com>
Sat, 28 Jan 2017 10:19:47 +0000 (10:19 +0000)
This fixes some destruction-of-locked-mutex errors in RawByteChannel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293375 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/Orc/RPCUtils.h
include/llvm/ExecutionEngine/Orc/RawByteChannel.h

index e739c72629854637d89ecec53a5842da05dc6abc..272b480565b38a520d2a100c10b0f251ec1a033e 100644 (file)
@@ -813,20 +813,20 @@ public:
     // Open the function call message.
     if (auto Err = C.startSendMessage(FnId, SeqNo)) {
       abandonPendingResponses();
-      return joinErrors(std::move(Err), C.endSendMessage());
+      return Err;
     }
 
     // Serialize the call arguments.
     if (auto Err = detail::HandlerTraits<typename Func::Type>::serializeArgs(
             C, Args...)) {
       abandonPendingResponses();
-      return joinErrors(std::move(Err), C.endSendMessage());
+      return Err;
     }
 
     // Close the function call messagee.
     if (auto Err = C.endSendMessage()) {
       abandonPendingResponses();
-      return std::move(Err);
+      return Err;
     }
 
     return Error::success();
index 3b6c84eb1965000dc6262cb958cacb074926620a..ce01c663afecb6651d850b5011298d056ce5d665 100644 (file)
@@ -48,7 +48,11 @@ public:
   template <typename FunctionIdT, typename SequenceIdT>
   Error startSendMessage(const FunctionIdT &FnId, const SequenceIdT &SeqNo) {
     writeLock.lock();
-    return serializeSeq(*this, FnId, SeqNo);
+    if (auto Err = serializeSeq(*this, FnId, SeqNo)) {
+      writeLock.unlock();
+      return Err;
+    }
+    return Error::success();
   }
 
   /// Notify the channel that we're ending a message send.
@@ -63,7 +67,11 @@ public:
   template <typename FunctionIdT, typename SequenceNumberT>
   Error startReceiveMessage(FunctionIdT &FnId, SequenceNumberT &SeqNo) {
     readLock.lock();
-    return deserializeSeq(*this, FnId, SeqNo);
+    if (auto Err = deserializeSeq(*this, FnId, SeqNo)) {
+      readLock.unlock();
+      return Err;
+    }
+    return Error::success();
   }
 
   /// Notify the channel that we're ending a message receive.