Skip to content

Commit 5a43f49

Browse files
committed
[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
1 parent a8dd82b commit 5a43f49

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

include/llvm/ExecutionEngine/Orc/RPCUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,20 +813,20 @@ class RPCEndpointBase {
813813
// Open the function call message.
814814
if (auto Err = C.startSendMessage(FnId, SeqNo)) {
815815
abandonPendingResponses();
816-
return joinErrors(std::move(Err), C.endSendMessage());
816+
return Err;
817817
}
818818

819819
// Serialize the call arguments.
820820
if (auto Err = detail::HandlerTraits<typename Func::Type>::serializeArgs(
821821
C, Args...)) {
822822
abandonPendingResponses();
823-
return joinErrors(std::move(Err), C.endSendMessage());
823+
return Err;
824824
}
825825

826826
// Close the function call messagee.
827827
if (auto Err = C.endSendMessage()) {
828828
abandonPendingResponses();
829-
return std::move(Err);
829+
return Err;
830830
}
831831

832832
return Error::success();

include/llvm/ExecutionEngine/Orc/RawByteChannel.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ class RawByteChannel {
4848
template <typename FunctionIdT, typename SequenceIdT>
4949
Error startSendMessage(const FunctionIdT &FnId, const SequenceIdT &SeqNo) {
5050
writeLock.lock();
51-
return serializeSeq(*this, FnId, SeqNo);
51+
if (auto Err = serializeSeq(*this, FnId, SeqNo)) {
52+
writeLock.unlock();
53+
return Err;
54+
}
55+
return Error::success();
5256
}
5357

5458
/// Notify the channel that we're ending a message send.
@@ -63,7 +67,11 @@ class RawByteChannel {
6367
template <typename FunctionIdT, typename SequenceNumberT>
6468
Error startReceiveMessage(FunctionIdT &FnId, SequenceNumberT &SeqNo) {
6569
readLock.lock();
66-
return deserializeSeq(*this, FnId, SeqNo);
70+
if (auto Err = deserializeSeq(*this, FnId, SeqNo)) {
71+
readLock.unlock();
72+
return Err;
73+
}
74+
return Error::success();
6775
}
6876

6977
/// Notify the channel that we're ending a message receive.

0 commit comments

Comments
 (0)