From ff0019a9ce0b8b717b8d14f0907004adc804f5c2 Mon Sep 17 00:00:00 2001 From: Arnaud Legrand Date: Tue, 3 Apr 2012 01:16:32 +0200 Subject: [PATCH] On a timeout we do not wait anymore on a task. -> Avoid keeping a pointer to an invalid object. --- src/simix/smx_user.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 1f5f4b4f1a..c0198ab3ed 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -17,6 +17,7 @@ #include "smx_private.h" #include "mc/mc.h" +#include "xbt/ex.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); @@ -1078,6 +1079,8 @@ void simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) { + xbt_ex_t e; + xbt_assert(isfinite(timeout), "timeout is not finite!"); smx_simcall_t simcall = SIMIX_simcall_mine(); @@ -1087,7 +1090,20 @@ void simcall_cond_wait_timeout(smx_cond_t cond, simcall->cond_wait_timeout.mutex = mutex; simcall->cond_wait_timeout.timeout = timeout; - SIMIX_simcall_push(simcall->issuer); + TRY { + SIMIX_simcall_push(simcall->issuer); + } + CATCH(e) { + switch (e.category) { + case timeout_error: + simcall->issuer->waiting_action = NULL; // FIXME: should clean ? + break; + default: + break; + } + RETHROW; + xbt_ex_free(e); + } } void simcall_cond_broadcast(smx_cond_t cond) -- 2.20.1