Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Read smpi_process_count() from remote process
[simgrid.git] / src / bindings / java / jmsg.c
index 4e06717..c11ba91 100644 (file)
@@ -67,8 +67,11 @@ void jmsg_throw_status(JNIEnv *env, msg_error_t status) {
     case MSG_HOST_FAILURE:
         jxbt_throw_host_failure(env,NULL);
     break;
+    case MSG_TASK_CANCELED:
+        jxbt_throw_task_cancelled(env,NULL);
+    break;
     default:
-        jxbt_throw_native(env,xbt_strdup("communication failed"));
+        jxbt_throw_native(env,xbt_strdup("undefined message failed (please see jmsg_throw_status function in jmsg.c)"));
   }
 }
 
@@ -180,11 +183,12 @@ JNIEXPORT void JNICALL
 
   /* Cleanup java storages */
   storages = MSG_storages_as_dynar();
-  for (index = 0; index < xbt_dynar_length(storages) - 1; index++) {
-    jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
-    if (jstorage)
-      jstorage_unref(env, jstorage);
-
+  if(!xbt_dynar_is_empty(storages)){
+    for (index = 0; index < xbt_dynar_length(storages) - 1; index++) {
+      jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
+      if (jstorage)
+        jstorage_unref(env, jstorage);
+    }
   }
   xbt_dynar_free(&storages);