From: Arnaud Giersch Date: Tue, 20 May 2014 13:02:22 +0000 (+0200) Subject: Fix race condition. X-Git-Tag: v3_11~60 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6ae9aaa5eb4561674a1552c1a628ad0297682460?ds=inline Fix race condition. Avoid to launch and cancel the task at the same time. It seems to work with HAVE_TRACING, but fails without. In fact, the task cancelation happens before the task starts to execute. As a workaround, add a small delay before firing up the cancel. --- diff --git a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c index 6dda8b5a96..20816633f1 100644 --- a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c +++ b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c @@ -114,6 +114,7 @@ int slave(int argc, char *argv[]) if (!strcmp(MSG_task_get_name(task), "cancel")) { MSG_process_create("worker1", worker_main, task, MSG_host_self()); + MSG_process_sleep(0.1); XBT_INFO("Canceling task \"%s\"", task->name); MSG_task_cancel(task); continue; diff --git a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.tesh b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.tesh index c20f5ce770..07f0c68887 100644 --- a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.tesh +++ b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.tesh @@ -9,10 +9,10 @@ $ ./task_destroy_cancel ${srcdir:=.}/task_destroy_cancel_p.xml ${srcdir:=.}/task > [Jupiter:slave:(2) 0.682345] [msg_test/INFO] Task "normal" done in 0.655342 (amount 0.000000) > [Jupiter:slave:(2) 0.709348] [msg_test/INFO] Handling task "cancel" > [Jupiter:worker1:(3) 0.709348] [msg_test/INFO] Start cancel -> [Jupiter:slave:(2) 0.709348] [msg_test/INFO] Canceling task "cancel" -> [Jupiter:worker1:(3) 0.710127] [msg_test/INFO] Task failed -> [Tremblay:master:(1) 0.736350] [msg_test/INFO] Goodbye now! -> [Jupiter:slave:(2) 0.736350] [msg_test/INFO] Handling task "finalize" -> [Jupiter:slave:(2) 0.736350] [msg_test/INFO] Destroying task "finalize" -> [Jupiter:slave:(2) 0.736350] [msg_test/INFO] I'm done. See you! -> [0.736350] [msg_test/INFO] Simulation time 0.73635 +> [Jupiter:slave:(2) 0.809348] [msg_test/INFO] Canceling task "cancel" +> [Jupiter:worker1:(3) 0.810127] [msg_test/INFO] Task failed +> [Tremblay:master:(1) 0.836350] [msg_test/INFO] Goodbye now! +> [Jupiter:slave:(2) 0.836350] [msg_test/INFO] Handling task "finalize" +> [Jupiter:slave:(2) 0.836350] [msg_test/INFO] Destroying task "finalize" +> [Jupiter:slave:(2) 0.836350] [msg_test/INFO] I'm done. See you! +> [0.836350] [msg_test/INFO] Simulation time 0.83635