[Zodb-checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.44
Jeremy Hylton
jeremy@zope.com
Wed, 14 Aug 2002 15:46:28 -0400
Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv20731
Modified Files:
ClientStorage.py
Log Message:
Small but important correction to condition variable protocol!
After setting self._transaction, release the lock. Then reacquire it
before the notify(). The wait() call is sufficient to block the other
threads; holding the lock is not necessary.
As a result, it doesn't matter if the same thread calls tpc_begin()
and tpc_abort() for a given transaction. So remove assertion.
=== ZODB3/ZEO/ClientStorage.py 1.43 => 1.44 ===
--- ZODB3/ZEO/ClientStorage.py:1.43 Wed Aug 14 12:22:23 2002
+++ ZODB3/ZEO/ClientStorage.py Wed Aug 14 15:46:28 2002
@@ -63,13 +63,6 @@
disconnected_stub = DisconnectedServerStub()
-import thread
-
-def check_thread_id(txn):
- if txn._id is None: # We can't tell what thread created this
- return 1
- return txn._id == thread.get_ident()
-
class ClientStorage:
def __init__(self, addr, storage='1', cache_size=20000000,
@@ -333,13 +326,13 @@
def tpc_abort(self, transaction):
if transaction is not self._transaction:
return
- assert check_thread_id(transaction)
try:
self._server.tpc_abort(self._serial)
self._tbuf.clear()
self._seriald.clear()
del self._serials[:]
finally:
+ self.tpc_cond.acquire()
self._transaction = None
self.tpc_cond.notify()
self.tpc_cond.release()
@@ -358,6 +351,7 @@
self.tpc_cond.release()
return
self.tpc_cond.wait()
+ self.tpc_cond.release()
if self._server is None:
self.tpc_cond.release()
@@ -393,7 +387,6 @@
def tpc_finish(self, transaction, f=None):
if transaction is not self._transaction:
return
- assert check_thread_id(transaction)
try:
if f is not None:
f()
@@ -405,6 +398,7 @@
self._update_cache()
finally:
+ self.tpc_cond.acquire()
self._transaction = None
self.tpc_cond.notify()
self.tpc_cond.release()