From 19da87ea5f64e0280c31385a7599bd82b27d28a4 Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Fri, 9 May 2008 22:19:42 -0700 Subject: [PATCH] Schedule a re-ping message after adding a new node. Also fixed a typo in the new nodeFailed function. --- apt_p2p_Khashmir/khashmir.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apt_p2p_Khashmir/khashmir.py b/apt_p2p_Khashmir/khashmir.py index 607c49b..54951b7 100644 --- a/apt_p2p_Khashmir/khashmir.py +++ b/apt_p2p_Khashmir/khashmir.py @@ -226,7 +226,13 @@ class KhashmirBase(protocol.Factory): df.addErrback(self._staleNodeHandler, old, node, contacted) elif not old and not contacted: # There's room, we just need to contact the node first - self.sendPing(node) + df = self.sendPing(node) + # Also schedule a future ping to make sure the node works + def rePing(newnode, self = self): + if newnode.id not in self.pinging: + self.pinging[newnode.id] = reactor.callLater(self.config['MIN_PING_INTERVAL'], + self.sendPing, newnode) + df.addCallback(rePing) def _staleNodeHandler(self, err, old, node, contacted): """The pinged node never responded, so replace it.""" @@ -244,7 +250,7 @@ class KhashmirBase(protocol.Factory): # If in the table, schedule a ping, if one isn't already sent/scheduled if exists and node.id not in self.pinging: - self.pinging[node,id] = reactor.callLater(self.config['MIN_PING_INTERVAL'], + self.pinging[node.id] = reactor.callLater(self.config['MIN_PING_INTERVAL'], self.sendPing, node) def sendPing(self, node): -- 2.39.5