From: Arnaud Giersch Date: Fri, 4 May 2018 21:30:51 +0000 (+0200) Subject: Fix for s4u::ConditionVariable::wait_for, lost by previous commit. X-Git-Tag: v3.20~286 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/128fe1a78cca2649fbe50297fa7750bc497ff324 Fix for s4u::ConditionVariable::wait_for, lost by previous commit. --- diff --git a/src/s4u/s4u_ConditionVariable.cpp b/src/s4u/s4u_ConditionVariable.cpp index 61d8c9c02c..c42a524daf 100644 --- a/src/s4u/s4u_ConditionVariable.cpp +++ b/src/s4u/s4u_ConditionVariable.cpp @@ -41,25 +41,12 @@ std::cv_status s4u::ConditionVariable::wait_for(std::unique_lock& lock, d if (timeout < 0) timeout = 0.0; - try { - simcall_cond_wait_timeout(cond_, lock.mutex()->mutex_, timeout); + if (simcall_cond_wait_timeout(cond_, lock.mutex()->mutex_, timeout)) { + // If we reached the timeout, we have to take the lock again: + lock.mutex()->lock(); + return std::cv_status::timeout; + } else { return std::cv_status::no_timeout; - } catch (xbt_ex& e) { - - // If the exception was a timeout, we have to take the lock again: - if (e.category == timeout_error) { - try { - lock.mutex()->lock(); - return std::cv_status::timeout; - } catch (...) { - std::terminate(); - } - } - - // Another exception: should we reaquire the lock? - std::terminate(); - } catch (...) { - std::terminate(); } }