From 22c8f349c3475e4bee6df083cc1871f45da2aecb Mon Sep 17 00:00:00 2001 From: agiersch Date: Wed, 1 Dec 2010 22:00:30 +0000 Subject: [PATCH] Do not duplicate rctx_wait_bg in rctx_exit git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8842 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- tools/tesh/run_context.c | 30 +++++++++--------------------- tools/tesh/tesh.c | 1 + 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/tesh/run_context.c b/tools/tesh/run_context.c index dc19f3f147..d8e21f3afd 100644 --- a/tools/tesh/run_context.c +++ b/tools/tesh/run_context.c @@ -101,21 +101,11 @@ void rctx_init(void) void rctx_exit(void) { int i; - if (bg_jobs) { - /* Do not use xbt_dynar_free or it will lock the dynar, preventing armageddon from working */ - while (xbt_dynar_length(bg_jobs)) { - rctx_t rctx = xbt_dynar_getlast_as(bg_jobs, rctx_t); - wait_it(rctx); - xbt_dynar_pop(bg_jobs, &rctx); - rctx_free(rctx); - } - } for (i = 0; i < 3; i++) sigaction(oldact[i].num, &oldact[i].act, NULL); xbt_os_cond_signal(sigwaiter_cond); xbt_os_thread_join(sigwaiter_thread, NULL); - if (bg_jobs) - xbt_dynar_free(&bg_jobs); + xbt_dynar_free(&bg_jobs); xbt_os_cond_destroy(sigwaiter_cond); xbt_os_mutex_destroy(sigwaiter_mutex); xbt_os_mutex_destroy(armageddon_mutex); @@ -123,17 +113,15 @@ void rctx_exit(void) void rctx_wait_bg(void) { - if (bg_jobs) { - /* Do not use xbt_dynar_free or it will lock the dynar, preventing armageddon from working */ - while (xbt_dynar_length(bg_jobs)) { - rctx_t rctx = xbt_dynar_getlast_as(bg_jobs, rctx_t); - wait_it(rctx); - xbt_dynar_pop(bg_jobs, &rctx); - rctx_free(rctx); - } - xbt_dynar_free(&bg_jobs); + /* Do not use xbt_dynar_free or it will lock the dynar, preventing armageddon + * from working */ + while (xbt_dynar_length(bg_jobs)) { + rctx_t rctx = xbt_dynar_getlast_as(bg_jobs, rctx_t); + wait_it(rctx); + xbt_dynar_pop(bg_jobs, &rctx); + rctx_free(rctx); } - bg_jobs = xbt_dynar_new_sync(sizeof(rctx_t), kill_it); + xbt_dynar_reset(bg_jobs); } static void rctx_armageddon_kill_one(rctx_t initiator, const char *filepos, diff --git a/tools/tesh/tesh.c b/tools/tesh/tesh.c index f4a3c89920..f45d0b1aed 100644 --- a/tools/tesh/tesh.c +++ b/tools/tesh/tesh.c @@ -243,6 +243,7 @@ int main(int argc, char *argv[]) INFO0("Test suite from stdin"); testsuite_name = "(stdin)"; handle_suite(testsuite_name, stdin); + rctx_wait_bg(); INFO0("Test suite from stdin OK"); } else { -- 2.20.1