From a9ef1f64d6c756706d6b6089215fe4c216f37b21 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 2 Oct 2018 07:01:44 -0700 Subject: Handled uncaught exception in Wait function --- .../utils/src/conditional_variable_boost.cc | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src') 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)) { - // Regular lock - cond_var_.wait(test_lock->mutex_); - } else if (RecursiveLock* test_rec_lock = - dynamic_cast(&lock)) { - // Recursive lock - cond_var_.wait(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)) { + // Regular lock + cond_var_.wait(test_lock->mutex_); + } else if (RecursiveLock* test_rec_lock = + dynamic_cast(&lock)) { + // Recursive lock + cond_var_.wait(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; -- cgit v1.2.1