From e514a3e8911d5c0e118436c56d7003f38dd255ee Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 28 Apr 2022 15:12:54 +0100 Subject: [PATCH] svc/connect.in: Stash the time in a variable rather than fetching inline. --- svc/connect.in | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/svc/connect.in b/svc/connect.in index cec1e3ff..1d34539b 100644 --- a/svc/connect.in +++ b/svc/connect.in @@ -407,11 +407,12 @@ class PingPeer (object): me._sigma_t = 0 me._sigma_t2 = 0 me._min = me._max = '-' + now = time() if pingnow: me._timer = None me._ping() else: - me._timer = M.SelTimer(time() + me._every, me._time) + me._timer = M.SelTimer(now + me._every, me._time) def update(me, peer): """ @@ -441,13 +442,14 @@ class PingPeer (object): me._peer])) def _reconnect(me): + now = time() try: peer = Peer(me._peer) if me._connectp or me._knockp: S.warn('connect', 'reconnecting', me._peer) S.forcekx(me._peer, quiet = not me._knockp) if me._connectp: T.spawn(run_connect, peer, peer.get('connect')) - me._timer = M.SelTimer(time() + me._every, me._time) + me._timer = M.SelTimer(now + me._every, me._time) me._sabotage = False else: S.kill(me._peer) @@ -466,6 +468,7 @@ class PingPeer (object): If the ping fails and we run out of retries, we attempt to restart the connection. """ + now = time() if code == 'TIMER': me._failures = 0 me._ping() @@ -487,7 +490,7 @@ class PingPeer (object): me._nping += 1 if me._min == '-' or t < me._min: me._min = t if me._max == '-' or t > me._max: me._max = t - me._timer = M.SelTimer(time() + me._every, me._time) + me._timer = M.SelTimer(now + me._every, me._time) elif outcome == 'ping-timeout': me._failures += 1 me._nlost += 1 @@ -862,6 +865,7 @@ def cmd_passive(*args): Report a challenge; when (and if!) the server receives a greeting quoting this challenge, add the corresponding peer to the server. """ + now = time() timeout = 30 op = T.OptParse(args, ['-timeout']) for opt in op: @@ -874,7 +878,7 @@ def cmd_passive(*args): except KeyError: raise T.TripeJobError('unknown-peer', name) chal = S.getchal() cr = T.Coroutine.getcurrent() - timer = M.SelTimer(time() + timeout, lambda: cr.switch(None)) + timer = M.SelTimer(now + timeout, lambda: cr.switch(None)) try: T.svcinfo(chal) chalmap[chal] = cr -- 2.11.0