The `ip' variable wasn't doing anything except remembering whether we'd
found a match, so replace it with a flag. This frees up the `ip' name,
so give that to the bizarrely named `ipq' variable which holds the
discovered local address.
if T._debug: print '# check group %s' % g
## Find out which peer in the group ought to be active.
if T._debug: print '# check group %s' % g
## Find out which peer in the group ought to be active.
statemap = {}
want = None
statemap = {}
want = None
- if p is None or not upness:
- ipq = addr
- else:
- ipq = localaddr(p)
+ if p is None or not upness: ip = addr
+ else: ip = localaddr(p)
if T._debug:
info = 'peer=%s; target=%s; net=%s; local=%s' % (
if T._debug:
info = 'peer=%s; target=%s; net=%s; local=%s' % (
- t, p or '(default)', n, straddr(ipq))
- if upness and ip is None and \
- ipq is not None and ipq.withinp(n):
+ t, p or '(default)', n, straddr(ip))
+ if upness and not matchp and \
+ ip is not None and ip.withinp(n):
if T._debug: print '# %s: SELECTED' % info
statemap[t] = 'up'
select.append('%s=%s' % (g, t))
if T._debug: print '# %s: SELECTED' % info
statemap[t] = 'up'
select.append('%s=%s' % (g, t))
- if t == 'down' or t.startswith('down/'):
- want = None
- else:
- want = t
- ip = ipq
+ if t == 'down' or t.startswith('down/'): want = None
+ else: want = t
+ matchp = True
else:
statemap[t] = 'down'
if T._debug: print '# %s: skipped' % info
else:
statemap[t] = 'down'
if T._debug: print '# %s: skipped' % info