[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Bug 29] Use explicit values for blocking=0/1 for Lockfi...
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv29341/lib/mixminion
Modified Files:
ClientMain.py Common.py
Log Message:
[Bug 29] Use explicit values for blocking=0/1 for Lockfile.acquire.
It turns out that the default behavior (blocking=0) did _not_ obey the
threading.*Lock interface, which in turn threw ClientDirectory for a
loop.
If the directory tried to acquire the lock, and there was contention,
it would die with an exception. Not any more, I hope.
In 0.0.8, we should change Lockfile to Do The Right Thing.
Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -d -r1.172 -r1.173
--- ClientMain.py 23 Mar 2004 03:54:12 -0000 1.172
+++ ClientMain.py 23 Mar 2004 05:15:16 -0000 1.173
@@ -57,6 +57,14 @@
global _CLIENT_LOCKFILE
_CLIENT_LOCKFILE = Lockfile(filename)
+class ClientDiskLock:
+ """A wrapper around clientLock and clientUnlock to present a lock-like
+ interface, and default to blocking locks."""
+ def acquire(self):
+ clientLock()
+ def release(self):
+ clientUnlock()
+
class ClientKeyring:
"""Class to manage storing encrypted keys for a client. Right now, this
is limited to a single SURB decryption key. In the future, we may
@@ -949,7 +957,7 @@
assert _CLIENT_LOCKFILE
LOG.debug("Configuring server list")
self.directory = mixminion.ClientDirectory.ClientDirectory(
- userdir, _CLIENT_LOCKFILE)
+ userdir, ClientDiskLock())
self.directory.configure(self.config)
self.directory._installAsKeyIDResolver()
Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- Common.py 23 Mar 2004 00:13:55 -0000 1.136
+++ Common.py 23 Mar 2004 05:15:16 -0000 1.137
@@ -1490,7 +1490,11 @@
"""Acquire this lock. If we're acquiring the lock for the first time,
write 'contents' to the lockfile. If 'blocking' is true, wait
until we can acquire the lock. If 'blocking' is false, raise
- LockfileLocked if we can't acquire the lock."""
+ LockfileLocked if we can't acquire the lock.
+
+ XXXX008 NOTE: This doesn't match the standard lock interface, which
+ defaults to blocking=1. This should change. XXXX008
+ """
if self.count > 0:
self.count += 1