Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix in Process.waitFor and Process.sleep: Throw the expected
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Mon, 21 May 2012 08:39:23 +0000 (10:39 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Mon, 21 May 2012 08:39:23 +0000 (10:39 +0200)
exception if failure.

org/simgrid/msg/Process.java
src/jmsg_process.c

index 5e1b4e6..abdd52c 100644 (file)
@@ -310,7 +310,7 @@ public abstract class Process implements Runnable {
         * FIXME: Not optimal, maybe we should have two native functions.
         * @param millis the length of time to sleep in milliseconds.
         */
         * FIXME: Not optimal, maybe we should have two native functions.
         * @param millis the length of time to sleep in milliseconds.
         */
-       public static void sleep(long millis)  {
+       public static void sleep(long millis) throws HostFailureException  {
                sleep(millis,0);
        }
        /**
                sleep(millis,0);
        }
        /**
@@ -321,12 +321,12 @@ public abstract class Process implements Runnable {
         * @param millis the length of time to sleep in milliseconds.
         * @param nanos additionnal nanoseconds to sleep.
         */
         * @param millis the length of time to sleep in milliseconds.
         * @param nanos additionnal nanoseconds to sleep.
         */
-       public native static void sleep(long millis, int nanos);
+       public native static void sleep(long millis, int nanos) throws HostFailureException;
        /**
         * Makes the current process sleep until time seconds have elapsed.
         * @param seconds               The time the current process must sleep.
         */ 
        /**
         * Makes the current process sleep until time seconds have elapsed.
         * @param seconds               The time the current process must sleep.
         */ 
-       public native void waitFor(double seconds);    
+       public native void waitFor(double seconds) throws HostFailureException;    
        /**
      *
      */
        /**
      *
      */
index 213b345..85c476f 100644 (file)
@@ -267,8 +267,9 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
        CATCH_ANONYMOUS {
                return;
        }
        CATCH_ANONYMOUS {
                return;
        }
-       jxbt_check_res("MSG_process_sleep()", rv, MSG_OK,
-                 bprintf("unexpected error , please report this bug"));
+  if (rv != MSG_OK) {
+       jmsg_throw_status(env,rv);
+  }
 }
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess,
 }
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess,
@@ -288,7 +289,8 @@ Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess,
        return;
   }
   if (rv != MSG_OK) {
        return;
   }
   if (rv != MSG_OK) {
-//     smx_ctx_java_stop(smx_ctx_java_self());
+       XBT_INFO("Status NOK");
+       jmsg_throw_status(env,rv);
   }
 }
 
   }
 }