Skip to content

Commit

Permalink
[Orc][RPC] Unlock message send/receive locks on failure.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lhames committed Jan 28, 2017
1 parent a8dd82b commit 5a43f49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions include/llvm/ExecutionEngine/Orc/RPCUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<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();
Expand Down
12 changes: 10 additions & 2 deletions include/llvm/ExecutionEngine/Orc/RawByteChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class RawByteChannel {
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.
Expand All @@ -63,7 +67,11 @@ class RawByteChannel {
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.
Expand Down

0 comments on commit 5a43f49

Please sign in to comment.