From 5a43f49c09087063fe4dfad2ac770b8a06078fbc Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sat, 28 Jan 2017 10:19:47 +0000 Subject: [PATCH] [Orc][RPC] Unlock message send/receive locks on failure. 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 | 6 +++--- include/llvm/ExecutionEngine/Orc/RawByteChannel.h | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/llvm/ExecutionEngine/Orc/RPCUtils.h b/include/llvm/ExecutionEngine/Orc/RPCUtils.h index e739c72629854..272b480565b38 100644 --- a/include/llvm/ExecutionEngine/Orc/RPCUtils.h +++ b/include/llvm/ExecutionEngine/Orc/RPCUtils.h @@ -813,20 +813,20 @@ class RPCEndpointBase { // 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::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(); diff --git a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h index 3b6c84eb19650..ce01c663afecb 100644 --- a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h +++ b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h @@ -48,7 +48,11 @@ class RawByteChannel { template 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 @@ class RawByteChannel { template 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.