Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the same way of checking the state of the communication in process_sleep.
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Wed, 20 Jun 2012 12:36:51 +0000 (14:36 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Wed, 20 Jun 2012 12:36:51 +0000 (14:36 +0200)
src/msg/msg_gos.c
src/simix/smx_process.c

index 4b5ff6d..9f04b7a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2011. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2012. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -234,7 +234,7 @@ MSG_error_t MSG_parallel_task_execute(m_task_t task)
  */
 MSG_error_t MSG_process_sleep(double nb_sec)
 {
-  e_smx_state_t state;
+  xbt_ex_t e;
   /*m_process_t proc = MSG_process_self();*/
 
 #ifdef HAVE_TRACING
@@ -242,25 +242,32 @@ MSG_error_t MSG_process_sleep(double nb_sec)
 #endif
 
   /* create action to sleep */
-  state = simcall_process_sleep(nb_sec);
 
   /*proc->simdata->waiting_action = act_sleep;
 
   FIXME: check if not setting the waiting_action breaks something on msg
   
   proc->simdata->waiting_action = NULL;*/
-  
-  if (state == SIMIX_DONE) {
-#ifdef HAVE_TRACING
-  TRACE_msg_process_sleep_out(MSG_process_self());
-#endif
-    MSG_RETURN(MSG_OK);
-  } else {
-#ifdef HAVE_TRACING
-    TRACE_msg_process_sleep_out(MSG_process_self());
-#endif
-    MSG_RETURN(MSG_HOST_FAILURE);
+
+  TRY {
+    simcall_process_sleep(nb_sec);  
   }
+  CATCH(e) {
+    switch (e.category) {
+      case host_error:
+        #ifdef HAVE_TRACING
+          TRACE_msg_process_sleep_out(MSG_process_self());
+        #endif
+        MSG_RETURN(MSG_HOST_FAILURE);
+        break;    
+      default:
+        RETHROW;
+    }
+  }
+  #ifdef HAVE_TRACING
+    TRACE_msg_process_sleep_out(MSG_process_self());
+  #endif
+  MSG_RETURN(MSG_OK);
 }
 
 /** \ingroup msg_task_usage
index b9d8f8d..009e927 100644 (file)
@@ -582,7 +582,7 @@ void SIMIX_post_process_sleep(smx_action_t action)
 
     switch(surf_workstation_model->action_state_get(action->sleep.surf_sleep)){
       case SURF_ACTION_FAILED:
-        state = SIMIX_SRC_HOST_FAILURE;
+       SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
         break;
 
       case SURF_ACTION_DONE: