From b1beff1eba2cea8ed6f38a4f388275303470c753 Mon Sep 17 00:00:00 2001 From: Tom Goff Date: Wed, 12 Oct 2016 17:37:27 +0000 Subject: [PATCH] daemon: Wait longer for EMANE network interfaces to exist. When EMANE is still running. --- daemon/core/emane/emane.py | 16 ++++++++++++++++ daemon/core/netns/vif.py | 14 +++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/daemon/core/emane/emane.py b/daemon/core/emane/emane.py index dce55fcc..41d8a2ca 100644 --- a/daemon/core/emane/emane.py +++ b/daemon/core/emane/emane.py @@ -1153,6 +1153,22 @@ class Emane(ConfigurableManager): self.session.sdt.updatenodegeo(node.objid, lat, long, alt) return True + def emanerunning(self, node): + '''\ + Return True if an EMANE process associated with the given node + is running, False otherwise. + ''' + status = -1 + cmd = ['pkill', '-0', '-x', 'emane'] + try: + if self.version < self.EMANE092: + status = subprocess.call(cmd) + else: + status = node.cmd(cmd, wait=True) + except: + pass + return status == 0 + def emane_version(): 'Return the locally installed EMANE version identifier and string.' cmd = ('emane', '--version') diff --git a/daemon/core/netns/vif.py b/daemon/core/netns/vif.py index 7ceb15a4..5b5be036 100644 --- a/daemon/core/netns/vif.py +++ b/daemon/core/netns/vif.py @@ -116,7 +116,19 @@ class TunTap(PyCoreNetIf): def nodedevexists(): cmd = (IP_BIN, 'link', 'show', self.name) return self.node.cmd(cmd) - self.waitfor(nodedevexists) + count = 0 + while True: + try: + self.waitfor(nodedevexists) + break + except RuntimeError: + # check if this is an EMANE interface; if so, continue + # waiting if EMANE is still running + if count < 5 and isinstance(self.net, EmaneNode) and \ + self.node.session.emane.emanerunning(self.node): + count += 1 + else: + raise def install(self): ''' Install this TAP into its namespace. This is not done from the