Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not duplicate rctx_wait_bg in rctx_exit
authoragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Dec 2010 22:00:30 +0000 (22:00 +0000)
committeragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Dec 2010 22:00:30 +0000 (22:00 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8842 48e7efb5-ca39-0410-a469-dd3cf9ba447f

tools/tesh/run_context.c
tools/tesh/tesh.c

index dc19f3f..d8e21f3 100644 (file)
@@ -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,
index f4a3c89..f45d0b1 100644 (file)
@@ -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 {