Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Last corrections of Tesh tool.
[simgrid.git] / tools / tesh2 / src / timer.c
index 627746a..70e99d3 100644 (file)
@@ -14,7 +14,7 @@
  \r
 #include <timer.h>\r
 #include <command.h>\r
-\r
+#include <unit.h>\r
 \r
 \r
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
@@ -27,8 +27,6 @@ timer_new(command_t command)
 {\r
        ttimer_t timer;\r
        \r
-       /* TODO : check the parameter */\r
-       \r
        timer = xbt_new0(s_timer_t, 1);\r
        \r
        timer->command = command;\r
@@ -42,9 +40,11 @@ timer_new(command_t command)
 int\r
 timer_free(ttimer_t* ptr)\r
 {\r
-       /* TODO : check the parameter */\r
-       \r
+       if((*ptr)->started)\r
+               xbt_os_sem_destroy((*ptr)->started);\r
+\r
        free(*ptr);\r
+\r
        *ptr = NULL;\r
        \r
        return 0;\r
@@ -82,11 +82,21 @@ timer_start_routine(void* p)
 \r
        if(timer->timeouted && !command->failed && !command->successeded  && !command->interrupted)\r
        {\r
-               error_register("Command timed out", ECMDTIMEDOUT, command->context->command_line, command->unit->fstream->name);\r
+               ERROR3("[%s] `%s' timed out after %d sec", command->context->pos, command->context->command_line, command->context->timeout);\r
+\r
+\r
+               unit_set_error(command->unit, ECMDTIMEDOUT, 1);\r
+\r
                command_kill(command);\r
                command_handle_failure(command, csr_timeout);\r
-               \r
-               \r
+\r
+               while(!command->reader->done)\r
+                       xbt_os_thread_yield();\r
+\r
+               if(command->output->used)\r
+                       INFO2("[%s] Output on timeout:\n%s",command->context->pos, command->output->data);\r
+               else\r
+                       INFO1("[%s] No output before timeout",command->context->pos);\r
        }\r
        \r
        return NULL;\r