Fixing core dump in NS3/DCE caused by getting the DceApplication Pid too early
[nepi.git] / src / nepi / resources / ns3 / ns3wrapper.py
index eadd71f..c0f27be 100644 (file)
@@ -174,7 +174,16 @@ class NS3Wrapper(object):
 
     @property
     def is_running(self):
-        return self._started and not self.ns3.Simulator.IsFinished()
+        return self.is_started and not self.ns3.Simulator.IsFinished()
+
+    @property
+    def is_started(self):
+        if not self._started:
+            now = self.ns3.Simulator.Now()
+            if not now.IsZero():
+                self._started = True
+
+        return self._started
 
     @property
     def is_finished(self):
@@ -263,6 +272,9 @@ class NS3Wrapper(object):
         if operation == "isRunning":
             result = self.is_running
 
+        elif operation == "isStarted":
+            result = self.is_started
+
         elif operation == "isFinished":
             result = self.is_finished
 
@@ -406,8 +418,7 @@ class NS3Wrapper(object):
                 args = [self._condition])
         self._simulator_thread.setDaemon(True)
         self._simulator_thread.start()
-        self._started = True
-
+        
         ### DEBUG
         self.logger.debug("START")
 
@@ -570,7 +581,7 @@ class NS3Wrapper(object):
 
         return realkwargs
 
-    def _is_app_running(self, uuid): 
+    def _is_app_running(self, uuid):
         now = self.ns3.Simulator.Now()
         if now.IsZero():
             return False