From 6b134d1eaf1978677f743fa1756a12d0cfffaf3b Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 20 Feb 2013 17:49:48 +0100 Subject: [PATCH] Split the xml file, and destroy task, to fix memory leaks. --- teshsuite/msg/CMakeLists.txt | 3 ++- teshsuite/msg/pid.c | 7 ++++--- teshsuite/msg/pid.tesh | 4 ++-- teshsuite/msg/{pid.xml => pid_d.xml} | 8 -------- teshsuite/msg/pid_p.xml | 10 ++++++++++ 5 files changed, 18 insertions(+), 14 deletions(-) rename teshsuite/msg/{pid.xml => pid_d.xml} (59%) create mode 100644 teshsuite/msg/pid_p.xml diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index eeb9d84b80..4de0cde345 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -25,7 +25,8 @@ set(xml_files ${CMAKE_CURRENT_SOURCE_DIR}/get_sender.xml ${CMAKE_CURRENT_SOURCE_DIR}/get_sender_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/get_sender_p.xml - ${CMAKE_CURRENT_SOURCE_DIR}/pid.xml + ${CMAKE_CURRENT_SOURCE_DIR}/pid_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/pid_p.xml PARENT_SCOPE ) set(teshsuite_src diff --git a/teshsuite/msg/pid.c b/teshsuite/msg/pid.c index ef21c7858b..54c89014ad 100644 --- a/teshsuite/msg/pid.c +++ b/teshsuite/msg/pid.c @@ -36,7 +36,8 @@ static int killall(int argc, char *argv[]){ int i; for (i=0; i<3;i++) { res = MSG_task_receive(&(task), mailbox); - int pid = *((int*)MSG_task_get_data(task)); + int pid = *(int*)MSG_task_get_data(task); + MSG_task_destroy(task); XBT_INFO("Killing process \"%d\".", pid); MSG_process_kill(MSG_process_from_PID(pid)); task = NULL; @@ -55,10 +56,10 @@ int main(int argc, char *argv[]) MSG_function_register("sendpid", &sendpid); MSG_function_register("killall", &killall); - MSG_process_killall(atoi(argv[2])); + MSG_process_killall(atoi(argv[3])); MSG_create_environment(argv[1]); - MSG_launch_application(argv[1]); + MSG_launch_application(argv[2]); res = MSG_main(); if (res == MSG_OK) diff --git a/teshsuite/msg/pid.tesh b/teshsuite/msg/pid.tesh index 04b6943b93..a1894633d1 100644 --- a/teshsuite/msg/pid.tesh +++ b/teshsuite/msg/pid.tesh @@ -1,4 +1,4 @@ -$ msg/pid ${srcdir:=.}/msg/pid.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ msg/pid ${srcdir:=.}/msg/pid_p.xml ${srcdir:=.}/msg/pid_d.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sendpid@toto) Sending pid of "1". > [ 0.000000] (2:sendpid@toto) Sending pid of "2". > [ 0.000000] (3:sendpid@toto) Sending pid of "3". @@ -12,7 +12,7 @@ $ msg/pid ${srcdir:=.}/msg/pid.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.003247] (4:killall@toto) Killing process "3". > [ 0.003247] (3:sendpid@toto) Process "3" killed. -$ msg/pid ${srcdir:=.}/msg/pid.xml 2 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ msg/pid ${srcdir:=.}/msg/pid_p.xml ${srcdir:=.}/msg/pid_d.xml 2 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (2:sendpid@toto) Sending pid of "2". > [ 0.000000] (3:sendpid@toto) Sending pid of "3". > [ 0.000000] (4:sendpid@toto) Sending pid of "4". diff --git a/teshsuite/msg/pid.xml b/teshsuite/msg/pid_d.xml similarity index 59% rename from teshsuite/msg/pid.xml rename to teshsuite/msg/pid_d.xml index 8b7d1d83e4..7475570b65 100644 --- a/teshsuite/msg/pid.xml +++ b/teshsuite/msg/pid_d.xml @@ -1,17 +1,9 @@ - - - - - - - - diff --git a/teshsuite/msg/pid_p.xml b/teshsuite/msg/pid_p.xml new file mode 100644 index 0000000000..f1d4756827 --- /dev/null +++ b/teshsuite/msg/pid_p.xml @@ -0,0 +1,10 @@ + + + + + + + + + + -- 2.20.1