From: Arnaud Giersch Date: Mon, 3 May 2021 13:54:45 +0000 (+0200) Subject: Keep execution alive after timeout in sg_exec_wait_for. X-Git-Tag: v3.28~365 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fa87b694ef63aa4f3193029f4705cc3d96492f04 Keep execution alive after timeout in sg_exec_wait_for. --- diff --git a/examples/c/energy-exec-ptask/energy-exec-ptask.c b/examples/c/energy-exec-ptask/energy-exec-ptask.c index a92b767900..2356cc612f 100644 --- a/examples/c/energy-exec-ptask/energy-exec-ptask.c +++ b/examples/c/energy-exec-ptask/energy-exec-ptask.c @@ -47,7 +47,8 @@ static void runner(int argc, char* argv[]) communication_amounts[i * host_count + j] = 1e7; // 10 MB sg_exec_t exec = sg_actor_parallel_exec_init(host_count, hosts, computation_amounts, communication_amounts); - sg_exec_wait_for(exec, 1 /* timeout (in seconds)*/); + if (sg_exec_wait_for(exec, 1 /* timeout (in seconds)*/) == SG_ERROR_TIMEOUT) + sg_exec_cancel(exec); xbt_free(communication_amounts); xbt_free(computation_amounts); diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 7d9d44cecb..24e0111c3a 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -300,6 +300,7 @@ sg_error_t sg_exec_wait_for(sg_exec_t exec, double timeout) try { s4u_exec->wait_for(timeout); } catch (const simgrid::TimeoutException&) { + s4u_exec->add_ref(); // the wait_for timeouted, keep the exec alive status = SG_ERROR_TIMEOUT; } catch (const simgrid::CancelException&) { status = SG_ERROR_CANCELED;