Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
for some reasons, the PID was sometimes not inited correctly in Java
[simgrid.git] / src / bindings / java / org / simgrid / msg / Process.java
index e4c7900..ecc7cee 100644 (file)
@@ -217,8 +217,13 @@ public abstract class Process implements Runnable {
         *
         */ 
        public int getPID()  {
+               if (pid == -1) // Don't traverse the JNI barrier if you already have the answer
+                       pid = nativeGetPID(); 
                return pid;
        }
+       // This should not be used: the PID is supposed to be initialized from the C directly when the actor is created,
+       // but this sometimes fail, so let's play nasty but safe here.
+       private native int nativeGetPID();
        /**
         * This method returns the PID of the parent of a process.
         *