[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Make pinger run at least 5 minutes without crashing.



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv8798/lib/mixminion/server

Modified Files:
	Pinger.py ServerMain.py 
Log Message:
Make pinger run at least 5 minutes without crashing.

Index: Pinger.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Pinger.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Pinger.py	12 Dec 2004 22:28:40 -0000	1.14
+++ Pinger.py	12 Dec 2004 23:24:31 -0000	1.15
@@ -78,6 +78,8 @@
     #XXXX can only be used from one thread at a time.
     LOCKING_IS_COARSE = 1
     def __init__(self, location):
+        parent = os.path.split(location)[0]
+        createPrivateDir(parent)
         self._theConnection = sqlite.connect(location, autocommit=0)
         self._theCursor = self._theConnection.cursor()
 
@@ -676,8 +678,8 @@
 
         self._lock.acquire()
         try:
-            self._brokenChains = isBroken
-            self._interestingChains = isInteresting
+            self._brokenChains = brokenChains
+            self._interestingChains = interestingChains
         finally:
             self._lock.release()
 
@@ -754,6 +756,7 @@
         self._db.getConnection().commit()
 
     def calculateAll(self, outFname=None, now=None):
+        if now is None: now=time.time()
         LOG.info("Computing ping results.")
         LOG.info("Starting to compute server uptimes.")
         self.calculateUptimes(now, now-24*60*60*12)
@@ -925,7 +928,7 @@
         return previousMidnight(t)
 
     def _getPingInterval(self, path):
-        if self.pingLog.isInteresting.get(path, 0):
+        if self.pingLog._interestingChains.get(path, 0):
             return self.INTERESTING_INTERVAL
         else:
             return self.DULL_INTERVAL
@@ -1036,7 +1039,7 @@
 
     assert DATABASE_CLASSES.has_key(database)
     if location is None:
-        location = os.path.join(config.getWorkingDir(), "pinger", "pingdb")
+        location = os.path.join(config.getWorkDir(), "pinger", "pingdb")
     db = DATABASE_CLASSES[database](location)
     log = PingLog(db)
 

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- ServerMain.py	12 Dec 2004 22:28:40 -0000	1.139
+++ ServerMain.py	12 Dec 2004 23:24:31 -0000	1.140
@@ -202,8 +202,9 @@
                 if res.isDelivery():
                     if res.getExitType() == mixminion.Packet.PING_TYPE:
                         LOG.debug("Ping packet IN:%s decoded", handle)
+                        digest = mixminion.Crypto.sha1(res.getPayload())
                         if self.pingLog is not None:
-                            self.pingLog.processPing(res)
+                            self.pingLog.gotPing(digest)
                         else:
                             LOG.debug("Pinging not enabled; discarding packet")
                         self.removeMessage(handle)
@@ -998,17 +999,18 @@
                 self.pingGenerator.sendPings))
         if self.pingLog is not None:
             self.scheduleEvent(RecurringEvent(
-                now+self.pingLog.HEARTBEAT_INTERVAL,
+                now+mixminion.server.Pinger.HEARTBEAT_INTERVAL,
                 self.pingLog.heartbeat,
-                self.pingLog.HEARTBEAT_INTERVAL))
+                mixminion.server.Pinger.HEARTBEAT_INTERVAL))
             # FFFF if we aren't using a LOCKING_IS_COURSE database, we will
             # FFFF still want this to happen in another thread.
             #XXXX008 use symbolic constants here
             self.scheduleEvent(RecurringEvent(
                 now+3*60,
                 lambda self=self: self.pingLog.calculateAll(
-                 os.path.join(self.config.getWorkingDir(), "pinger", "status")),
-                1*60*60))
+                 os.path.join(self.config.getWorkDir(), "pinger", "status")),
+                #1*60*60))
+                10*60))
 
         # Makes next update get scheduled.
         nextUpdate = self.updateDirectoryClient()