BUgfix in ns3 testbed, when scheuling an event, the condition was released always...
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Mon, 8 Aug 2011 08:36:08 +0000 (10:36 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Mon, 8 Aug 2011 08:36:08 +0000 (10:36 +0200)
src/nepi/testbeds/ns3/execute.py

index ed9a57f..f94a063 100644 (file)
@@ -209,12 +209,14 @@ class TestbedController(testbed_impl.TestbedController):
         # bool flag, a list is used as wrapper
         has_event_occurred = [False]
         condition.acquire()
-        if not self.ns3.Simulator.IsFinished():
-            self.ns3.Simulator.ScheduleWithContext(contextId, delay, execute_event,
-                 condition, has_event_occurred, func, *args)
-            while not has_event_occurred[0] and not self.ns3.Simulator.IsFinished():
-                condition.wait()
-                condition.release()
+        try:
+            if not self.ns3.Simulator.IsFinished():
+                self.ns3.Simulator.ScheduleWithContext(contextId, delay, execute_event,
+                     condition, has_event_occurred, func, *args)
+                while not has_event_occurred[0] and not self.ns3.Simulator.IsFinished():
+                    condition.wait()
+        finally:
+            condition.release()
 
     def _set_attribute(self, name, ns3_value, element):
         if self.status() == TS.STATUS_STARTED: