From: Daira Hopwood Date: Tue, 25 Jun 2013 18:13:48 +0000 (+0100) Subject: iputil.py: fix an error handling bug. refs #1381 X-Git-Tag: allmydata-tahoe-1.10.1a1~234 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/index.php?a=commitdiff_plain;h=6104950ed8a7a356eed2218f2df958d074022eea;p=tahoe-lafs%2Ftahoe-lafs.git iputil.py: fix an error handling bug. refs #1381 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/util/iputil.py b/src/allmydata/util/iputil.py index d1b8fc9c..c1239f0e 100644 --- a/src/allmydata/util/iputil.py +++ b/src/allmydata/util/iputil.py @@ -145,7 +145,7 @@ _win32_commands = (('route.exe', ('print',), _win32_re),) # These work in most Unices. _addr_re = re.compile(r'^\s*inet [a-zA-Z]*:?(?P
\d+\.\d+\.\d+\.\d+)[\s/].+$', flags=re.M|re.I|re.S) -_unix_commands = (('/bin/ip addr', (), _addr_re), +_unix_commands = (('/bin/ip', ('addr',), _addr_re), ('/sbin/ifconfig', ('-a',), _addr_re), ('/usr/sbin/ifconfig', ('-a',), _addr_re), ('/usr/etc/ifconfig', ('-a',), _addr_re), @@ -189,14 +189,16 @@ def _synchronously_find_addresses_via_config(): def _query(path, args, regex): env = {'LANG': 'en_US.UTF-8'} - for trial in xrange(5): + TRIES = 5 + for trial in xrange(TRIES): try: p = subprocess.Popen([path] + list(args), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) (output, err) = p.communicate() break except OSError, e: - if e.errno == errno.EINTR: + if e.errno == errno.EINTR and trial < TRIES-1: continue + raise addresses = [] outputsplit = output.split('\n')