Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Dig through git history, and update copyright lines.
[simgrid.git] / src / bindings / java / jmsg_process.c
index b78ba98..ec9c9d4 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java process instances.                         */
 
-/* Copyright (c) 2007-2012. The SimGrid Team.
+/* Copyright (c) 2007-2013. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -132,7 +132,7 @@ Java_org_simgrid_msg_Process_create(JNIEnv * env,
   /* bind/retrieve the msg host */
   host = MSG_get_host_by_name(hostname);
 
-  if (!(host)) {    /* not binded */
+  if (!(host)) {    /* not bound */
     jxbt_throw_host_not_found(env, hostname);
     return;
   }
@@ -335,7 +335,7 @@ Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env,
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
  {
-  double time =  jmillis / 1000 + jnanos / 1000;
+  double time =  ((double)jmillis) / 1000 + ((double)jnanos) / 1000000000;
   msg_error_t rv;
   rv = MSG_process_sleep(time);
   if (rv != MSG_OK) {
@@ -348,6 +348,8 @@ Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess,
 {
   msg_error_t rv;
   rv = MSG_process_sleep((double)jseconds);
+  if ((*env)->ExceptionOccurred(env))
+    return;
   if (rv != MSG_OK) {
     XBT_DEBUG("Status NOK");
     jmsg_throw_status(env,rv);
@@ -389,6 +391,7 @@ Java_org_simgrid_msg_Process_migrate(JNIEnv * env,
   msg_error_t rv = MSG_process_migrate(process, host);
   if (rv != MSG_OK) {
     jmsg_throw_status(env,rv);
+    return;
   }
   /* change the host java side */
   (*env)->SetObjectField(env, jprocess, jprocess_field_Process_host, jhost);