Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Found a bug/feature regarding the cancellation of a sleep (see comments directly...
authorAdrien Lebre <alebre@pc18.home>
Mon, 28 Jul 2014 15:53:54 +0000 (17:53 +0200)
committerAdrien Lebre <alebre@pc18.home>
Mon, 28 Jul 2014 15:53:54 +0000 (17:53 +0200)
src/bindings/java/jmsg_process.c
src/msg/msg_gos.c
src/simix/smx_process.c

index 7bb72ea..8625d25 100644 (file)
@@ -340,7 +340,16 @@ Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint
   msg_error_t rv;
   rv = MSG_process_sleep(time);
   if (rv != MSG_OK) {
   msg_error_t rv;
   rv = MSG_process_sleep(time);
   if (rv != MSG_OK) {
-    jmsg_throw_status(env,rv);
+    XBT_DEBUG("Something during the MSG_process_sleep invocation was wrong, trigger a HostFailureException");
+
+    //jmsg_throw_status(env,rv);
+
+    // adsein, the code above as been replaced by the code below. Indeed, according to the documentation, a sleep can only 
+    // trigger a host_failure exception. When the sleep crashes due to a host shutdown, the exception thrown by smx_context_java.c
+    // is a cancelled_error, see bindings/java/smx_context_java.c, function void smx_ctx_java_stop(smx_context_t context) and src/msg/msg_gos.c
+    // function  msg_error_t MSG_process_sleep(double nb_sec)
+
+    jxbt_throw_host_failure(env,NULL);
   }
 }
 JNIEXPORT void JNICALL
   }
 }
 JNIEXPORT void JNICALL
index 447b68b..df8c0d3 100644 (file)
@@ -169,6 +169,13 @@ msg_error_t MSG_process_sleep(double nb_sec)
   CATCH(e) {
     switch (e.category) {
     case cancel_error:
   CATCH(e) {
     switch (e.category) {
     case cancel_error:
+      XBT_DEBUG("According to the JAVA API, a sleep call should only deal with HostFailureException, WTF here ?"); 
+      // adsein: MSG_TASK_CANCELED is assigned when someone kills the process that made the sleep, this is not
+      // correct. For instance, when the node is turned off, the error should be MSG_HOST_FAILURE, which is by the way
+      // and according to the JAVA document, the only exception that can be triggered by MSG_Process_sleep call.
+      // To avoid possible impacts in the code, I just raised a host_failure execption for the moment in the JAVA code 
+      // and did not change anythings at the C level.
+      // See comment in the jmsg_process.c file, function JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos) 
       status = MSG_TASK_CANCELED;
       break;
     default:
       status = MSG_TASK_CANCELED;
       break;
     default:
index 8d2320a..84bcef1 100644 (file)
@@ -759,7 +759,7 @@ void SIMIX_post_process_sleep(smx_action_t action)
     switch(surf_action_get_state(action->sleep.surf_sleep)){
       case SURF_ACTION_FAILED:
         simcall->issuer->context->iwannadie = 1;
     switch(surf_action_get_state(action->sleep.surf_sleep)){
       case SURF_ACTION_FAILED:
         simcall->issuer->context->iwannadie = 1;
-        //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
+       //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
         state = SIMIX_SRC_HOST_FAILURE;
         break;
 
         state = SIMIX_SRC_HOST_FAILURE;
         break;
 
@@ -840,6 +840,7 @@ void SIMIX_process_yield(smx_process_t self)
   if (self->context->iwannadie){
     XBT_DEBUG("I wanna die!");
     SIMIX_process_stop(self);
   if (self->context->iwannadie){
     XBT_DEBUG("I wanna die!");
     SIMIX_process_stop(self);
+    XBT_DEBUG("SIMIX Stop done");
   }
 
   if (self->suspended) {
   }
 
   if (self->suspended) {