chiark
/
gitweb
/
~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
server/tests.at: Add a retry loop in `COMMS_EPING'.
[tripe]
/
svc
/
conntrack.in
diff --git
a/svc/conntrack.in
b/svc/conntrack.in
index 47f66f4d4485660a861f009818eeb6e3694eeb2c..78141e6fe79bd2dd20b5426b0f44cf82c7a380fc 100644
(file)
--- a/
svc/conntrack.in
+++ b/
svc/conntrack.in
@@
-233,35
+233,59
@@
def kickpeers():
addr = localaddr(CF.testaddr)
if addr is None:
upness = False
addr = localaddr(CF.testaddr)
if addr is None:
upness = False
+ else:
+ addr = None
## Now decide what to do.
changes = []
for g, pp in CF.groups:
## Find out which peer in the group ought to be active.
## Now decide what to do.
changes = []
for g, pp in CF.groups:
## Find out which peer in the group ought to be active.
- want = None # unequal to any string
- if upness:
- for t, p, a, m in pp:
- if p is None:
- aq = addr
+ ip = None
+ map = {}
+ want = None
+ for t, p, a, m in pp:
+ if p is None or not upness:
+ ipq = addr
+ else:
+ ipq = localaddr(p)
+ if upness and ip is None and \
+ ipq is not None and (ipq & m) == a:
+ map[t] = 'up'
+ if t == 'down' or t.startswith('down/'):
+ want = None
else:
else:
- aq = localaddr(p)
- if aq is not None and (aq & m) == a:
want = t
want = t
- break
+ ip = ipq
+ else:
+ map[t] = 'down'
## Shut down the wrong ones.
found = False
for p in peers:
## Shut down the wrong ones.
found = False
for p in peers:
- if p == want:
+ what = map.get(p, 'leave')
+ if what == 'up':
found = True
found = True
- elif p.startswith(g) and p != want:
- changes.append(lambda p=p: SM.kill(p))
+ elif what == 'down':
+ def _(p = p):
+ try:
+ SM.kill(p)
+ except T.TripeError, exc:
+ if exc.args[0] == 'unknown-peer':
+ ## Inherently racy; don't worry about this.
+ pass
+ else:
+ raise
+ changes.append(_)
## Start the right one if necessary.
if want is not None and not found:
## Start the right one if necessary.
if want is not None and not found:
- changes.append(lambda: T._simple(SM.svcsubmit('connect', 'active',
- want)))
+ def _(want = want):
+ try:
+ SM.svcsubmit('connect', 'active', want)
+ except T.TripeError, exc:
+ SM.warn('conntrack', 'connect-failed', want, *exc.args)
+ changes.append(_)
## Commit the changes.
if changes:
## Commit the changes.
if changes: