Commit 634023b0 authored by Barry Warsaw's avatar Barry Warsaw

Clean up some whitespace, but not all.

tpc_begin(): Get rid of the apply() call since I believe we can now
rely on extended-call syntax being available.
parent 71a10da2
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
""" """
# Do this portably in the face of checking out with -kv # Do this portably in the face of checking out with -kv
import string import string
__version__ = string.split('$Revision: 1.21 $')[-2:][0] __version__ = string.split('$Revision: 1.22 $')[-2:][0]
import ThreadLock, bpthread import ThreadLock, bpthread
import time, UndoLogCompatible import time, UndoLogCompatible
...@@ -108,12 +108,14 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible): ...@@ -108,12 +108,14 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
def tpc_abort(self, transaction): def tpc_abort(self, transaction):
self._lock_acquire() self._lock_acquire()
try: try:
if transaction is not self._transaction: return if transaction is not self._transaction:
return
self._abort() self._abort()
self._clear_temp() self._clear_temp()
self._transaction=None self._transaction = None
self._commit_lock_release() self._commit_lock_release()
finally: self._lock_release() finally:
self._lock_release()
def _abort(self): def _abort(self):
"""Subclasses should redefine this to supply abort actions""" """Subclasses should redefine this to supply abort actions"""
...@@ -122,34 +124,36 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible): ...@@ -122,34 +124,36 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
def tpc_begin(self, transaction, tid=None, status=' '): def tpc_begin(self, transaction, tid=None, status=' '):
self._lock_acquire() self._lock_acquire()
try: try:
if self._transaction is transaction: return if self._transaction is transaction:
return
self._lock_release() self._lock_release()
self._commit_lock_acquire() self._commit_lock_acquire()
self._lock_acquire() self._lock_acquire()
self._transaction=transaction self._transaction = transaction
self._clear_temp() self._clear_temp()
user=transaction.user user = transaction.user
desc=transaction.description desc = transaction.description
ext=transaction._extension ext = transaction._extension
if ext: ext=dumps(ext,1) if ext:
else: ext="" ext = dumps(ext,1)
self._ude=user, desc, ext else:
ext=""
self._ude = user, desc, ext
if tid is None: if tid is None:
t=time.time() now = time.time()
t=apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,))) t = TimeStamp(*(time.gmtime(now)[:5] + (now % 60,)))
self._ts=t=t.laterThan(self._ts) self._ts = t = t.laterThan(self._ts)
self._serial=`t` self._serial = `t`
else: else:
self._ts=TimeStamp(tid) self._ts = TimeStamp(tid)
self._serial=tid self._serial = tid
self._tstatus=status
self._tstatus = status
self._begin(self._serial, user, desc, ext) self._begin(self._serial, user, desc, ext)
finally:
finally: self._lock_release() self._lock_release()
def _begin(self, tid, u, d, e): def _begin(self, tid, u, d, e):
"""Subclasses should redefine this to supply transaction start actions. """Subclasses should redefine this to supply transaction start actions.
...@@ -159,7 +163,8 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible): ...@@ -159,7 +163,8 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
def tpc_vote(self, transaction): def tpc_vote(self, transaction):
self._lock_acquire() self._lock_acquire()
try: try:
if transaction is not self._transaction: return if transaction is not self._transaction:
return
self._vote() self._vote()
finally: finally:
self._lock_release() self._lock_release()
...@@ -172,16 +177,17 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible): ...@@ -172,16 +177,17 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
def tpc_finish(self, transaction, f=None): def tpc_finish(self, transaction, f=None):
self._lock_acquire() self._lock_acquire()
try: try:
if transaction is not self._transaction: return if transaction is not self._transaction:
return
try: try:
if f is not None: f() if f is not None:
f()
u,d,e=self._ude u, d, e = self._ude
self._finish(self._serial, u, d, e) self._finish(self._serial, u, d, e)
self._clear_temp() self._clear_temp()
finally: finally:
self._ude=None self._ude = None
self._transaction=None self._transaction = None
self._commit_lock_release() self._commit_lock_release()
finally: finally:
self._lock_release() self._lock_release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment