From caffead47df585ba6594a74ffa3724691ed0e35c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christophe=20Thi=C3=A9ry?= Date: Thu, 13 Oct 2011 16:45:05 +0200 Subject: [PATCH] Fighting more memory leaks in Chord --- examples/msg/chord/chord.c | 11 ++++++++++- src/simix/smx_process.c | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/msg/chord/chord.c b/examples/msg/chord/chord.c index 082a555fd6..e916d85a9f 100644 --- a/examples/msg/chord/chord.c +++ b/examples/msg/chord/chord.c @@ -82,6 +82,7 @@ static int *powers2; // utility functions static void chord_initialize(void); +static void chord_exit(void); static int normalize(int id); static int is_in_interval(int id, int start, int end); static void get_mailbox(int host_id, char* mailbox); @@ -127,6 +128,11 @@ static void chord_initialize(void) XBT_DEBUG("Sets nb_keys to %d", nb_keys); } +static void chord_exit(void) +{ + xbt_free(powers2); +} + /** * \brief Turns an id into an equivalent id in [0, nb_keys). * \param id an id @@ -342,7 +348,9 @@ int node(int argc, char *argv[]) MSG_process_sleep(5); } } - else { + + if (node.comm_receive && MSG_comm_test(node.comm_receive)) { + // a transfer has occured MSG_error_t status = MSG_comm_get_status(node.comm_receive); @@ -914,6 +922,7 @@ int main(int argc, char *argv[]) XBT_INFO("Simulated time: %g", MSG_get_clock()); MSG_clean(); + chord_exit(); if (res == MSG_OK) return 0; diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index bf5707b098..7a169dde29 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -200,6 +200,8 @@ void SIMIX_process_kill(smx_process_t process) { process->blocked = 0; process->suspended = 0; /* FIXME: set doexception to 0 also? */ + /* FIXME: asynchronous communication actions are not destroyed: + * another process may find a matching rdv with me after I'm freed */ if (process->waiting_action) { -- 2.20.1