From 48f8657f6e8e5c52df45b067928860541f7598d9 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Mon, 8 Aug 2011 10:36:08 +0200 Subject: [PATCH] BUgfix in ns3 testbed, when scheuling an event, the condition was released always after a wait. --- src/nepi/testbeds/ns3/execute.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nepi/testbeds/ns3/execute.py b/src/nepi/testbeds/ns3/execute.py index ed9a57fd..f94a0630 100644 --- a/src/nepi/testbeds/ns3/execute.py +++ b/src/nepi/testbeds/ns3/execute.py @@ -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: -- 2.47.0