diff options
author | ShobhitAd <adlakhshobhit@gmail.com> | 2018-10-02 07:01:44 -0700 |
---|---|---|
committer | ShobhitAd <adlakhshobhit@gmail.com> | 2018-10-02 07:01:44 -0700 |
commit | a9ef1f64d6c756706d6b6089215fe4c216f37b21 (patch) | |
tree | f04e60bc91c14505d4a529452007eb727ec6f1d0 | |
parent | 060d3c4d95fe1439ce4ce57b34df964a786c0df4 (diff) | |
download | sdl_core-a9ef1f64d6c756706d6b6089215fe4c216f37b21.tar.gz |
Handled uncaught exception in Wait functionfix/5.0.0_coverity_other
-rw-r--r-- | src/components/utils/src/conditional_variable_boost.cc | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/components/utils/src/conditional_variable_boost.cc b/src/components/utils/src/conditional_variable_boost.cc index 91c75c6f3d..a74aa3eaa6 100644 --- a/src/components/utils/src/conditional_variable_boost.cc +++ b/src/components/utils/src/conditional_variable_boost.cc @@ -63,23 +63,27 @@ void ConditionalVariable::Broadcast() { bool ConditionalVariable::Wait(BaseLock& lock) { // NOTE this grossness is due to boost mutex and recursive mutex not sharing a // superclass - - lock.AssertTakenAndMarkFree(); - // What kind of lock are we ? - if (Lock* test_lock = dynamic_cast<Lock*>(&lock)) { - // Regular lock - cond_var_.wait<boost::mutex>(test_lock->mutex_); - } else if (RecursiveLock* test_rec_lock = - dynamic_cast<RecursiveLock*>(&lock)) { - // Recursive lock - cond_var_.wait<boost::recursive_mutex>(test_rec_lock->mutex_); - } else { - // unknown, give up the lock - LOG4CXX_ERROR(logger_, "Unknown lock type!"); + try { + lock.AssertTakenAndMarkFree(); + // What kind of lock are we ? + if (Lock* test_lock = dynamic_cast<Lock*>(&lock)) { + // Regular lock + cond_var_.wait<boost::mutex>(test_lock->mutex_); + } else if (RecursiveLock* test_rec_lock = + dynamic_cast<RecursiveLock*>(&lock)) { + // Recursive lock + cond_var_.wait<boost::recursive_mutex>(test_rec_lock->mutex_); + } else { + // unknown, give up the lock + LOG4CXX_ERROR(logger_, "Unknown lock type!"); + NOTREACHED(); + } + lock.AssertFreeAndMarkTaken(); + } catch (const boost::exception& error) { + std::string error_string = boost::diagnostic_information(error); + LOG4CXX_FATAL(logger_, error_string); NOTREACHED(); } - lock.AssertFreeAndMarkTaken(); - return true; } @@ -122,6 +126,7 @@ ConditionalVariable::WaitStatus ConditionalVariable::WaitFor( } catch (const boost::exception& error) { std::string error_string = boost::diagnostic_information(error); LOG4CXX_FATAL(logger_, error_string); + NOTREACHED(); } return wait_status; |