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

[minion-cvs] Act sensibly when a downloaded directory is bad.



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

Modified Files:
	ServerMain.py 
Log Message:
Act sensibly when a downloaded directory is bad.

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- ServerMain.py	23 Mar 2004 00:09:06 -0000	1.122
+++ ServerMain.py	23 Mar 2004 00:35:07 -0000	1.123
@@ -725,7 +725,12 @@
         LOG.debug("Initializing directory client")
         self.dirClient = mixminion.ClientDirectory.ClientDirectory(
             os.path.join(config.getWorkDir(),"dir"))
-        self.dirClient.updateDirectory()
+        try:
+            self.dirClient.updateDirectory()
+        except mixminion.ClientDirectory.GotInvalidDirectoryError, e:
+            LOG.warn(str(e))
+            LOG.warn("   (I'll use the old one until I get one that's good.)")
+
         self.dirClient._installAsKeyIDResolver()
 
         publishedIP, publishedPort, publishedKeyID = self.keyring.getAddress()
@@ -826,12 +831,18 @@
 
     def updateDirectoryClient(self):
         def c(self=self):
-            self.dirClient.updateDirectory()
-            prng = mixminion.Crypto.getCommonPRNG()
-            nextUpdate = succeedingMidnight(time.time())
-            # Randomly retrieve the directory within an hour after midnight, to
-            # avoid hosing the server.
-            nextUpdate += prng.getInt(60)*60
+            try:
+                self.dirClient.updateDirectory()
+                nextUpdate = succeedingMidnight(time.time()+30)
+                prng = mixminion.Crypto.getCommonPRNG()
+                # Randomly retrieve the directory within an hour after
+                # midnight, to avoid hosing the server.
+                nextUpdate += prng.getInt(60)*60
+            except mixminion.ClientDirectory.GotInvalidDirectoryError, e:
+                LOG.warn(str(e))
+                LOG.warn("    I'll try again in an hour.")
+                nextUpdate = min(succeedingMidnight(time.time()+30),
+                                 time.time()+3600)
             self.scheduleOnce(nextUpdate, "UPDATE_DIR_CLIENT",
                               self.updateDirectoryClient)
         self.processingThread.addJob(c)