Add exception handling for mutex or condition variable failures #268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RTT - or more specifically the
RTT::os::Mutex
,RTT::os::MutexRecursive
andRTT::os::Condition
implementations - were not checking for errors returned by the underlying OS system calls, which I think is a serious issue. As a consequence errors in using those primitives within RTT or in user code remain undetected which may lead to unpredictable and hard to debug behavior of Orocos applications.This pull request introduces exception handling in the
Mutex
,MutexRecursive
andCondition
implementations. In order to avoid ambiguity if the return value of a OS abstraction method (rtos_*()
) represents an error or not they now return negative values in the error case consistently and the absolute value holds the error code.I added a unit test (as part of the
core_test
) for the single thread behavior ofMutex
andMutexRecursive
. The test currently fails for the xenomai target, which might reveal a problem in the implementation ofrtos_mutex_unlock()
:Futhermore the IPC tests fail with this patch because the CORBA transport implementations tries to lock RTT mutexes from ORB threads, which is not allowed in Xenomai and triggers an exception now.