From: Arnaud Giersch Date: Tue, 7 May 2019 20:18:30 +0000 (+0200) Subject: Ensure the task is correctly destroyed when the host turns off during execute. X-Git-Tag: v3.22.4~127^2~45 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/42ec7509c27a32900f26d644d450e2ca367fee4e Ensure the task is correctly destroyed when the host turns off during execute. --- diff --git a/examples/deprecated/msg/platform-failures/platform-failures.c b/examples/deprecated/msg/platform-failures/platform-failures.c index 229a92993b..3a88921320 100644 --- a/examples/deprecated/msg/platform-failures/platform-failures.c +++ b/examples/deprecated/msg/platform-failures/platform-failures.c @@ -11,6 +11,12 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example") #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */ +static void task_cleanup_handler(void* task) +{ + if (task) + MSG_task_destroy(task); +} + static int master(int argc, char *argv[]) { long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); @@ -95,7 +101,9 @@ static int worker(int argc, char *argv[]) break; } XBT_INFO("Start execution..."); + MSG_process_set_data(MSG_process_self(), task); retcode = MSG_task_execute(task); + MSG_process_set_data(MSG_process_self(), NULL); if (retcode == MSG_OK) { XBT_INFO("Execution complete."); MSG_task_destroy(task); @@ -123,6 +131,7 @@ int main(int argc, char *argv[]) MSG_function_register("master", master); MSG_function_register("worker", worker); + MSG_process_set_data_cleanup(task_cleanup_handler); MSG_launch_application(argv[2]); msg_error_t res = MSG_main(); diff --git a/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp b/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp index 87cb748648..8f278b2fdf 100644 --- a/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp +++ b/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp @@ -156,7 +156,6 @@ static int test_launcher(int /*argc*/, char** /*argv*/) test = 6; if (xbt_dynar_search_or_negative(tests, &test) != -1) { XBT_INFO("Test 6: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node"); - MSG_process_set_data_cleanup(nullptr); // If set for test 6, cleanup handler gives double-free errors. // Create VM0 msg_vm_t vm0 = MSG_vm_create_core(jupiter, "vm0");