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

[minion-cvs] If another Mixminion process dropped the file lock betw...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria:/tmp/cvs-serv13386/lib/mixminion

Modified Files:
	ClientMain.py Common.py 
Log Message:
If another Mixminion process dropped the file lock between when you noticed you had it and when you mentioned that the other guy had it, you could crash.  Fix that. [Bug 38]

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- ClientMain.py	15 Jul 2005 20:42:26 -0000	1.185
+++ ClientMain.py	2 Dec 2005 18:50:21 -0000	1.186
@@ -47,7 +47,11 @@
     try:
         _CLIENT_LOCKFILE.acquire(blocking=0, contents=pidStr)
     except LockfileLocked:
-        LOG.info("Waiting for pid %s", _CLIENT_LOCKFILE.getContents())
+        c = _CLIENT_LOCKFILE.getContents()
+        if c:
+            LOG.info("Waiting for pid %s", c)
+        else:
+            LOG.info("Waiting for another process")
         _CLIENT_LOCKFILE.acquire(blocking=1, contents=pidStr)
 
 def clientUnlock():

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- Common.py	28 Nov 2005 17:11:20 -0000	1.148
+++ Common.py	2 Dec 2005 18:50:22 -0000	1.149
@@ -1634,8 +1634,13 @@
         self.rlock = threading.Lock() #DOCDOC
 
     def getContents(self):
-        """Return the contents of the lock file."""
-        return readFile(self.filename)
+        """Return the contents of the lock file, or None if it has been
+           removed from underneath us.
+        """
+        try:
+            return readFile(self.filename)
+        except (IOError, OSError), _:
+            return None
 
     def acquire(self, contents="", blocking=0, mode=0600):
         """Acquire this lock.  If we're acquiring the lock for the first time,