Commit 64937bef authored by Jim Fulton's avatar Jim Fulton

history wasn't protected by a lock.

parent 7991e191
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.38 $'[11:-2] __version__='$Revision: 1.39 $'[11:-2]
import struct, time, os, bpthread, string, base64, sys import struct, time, os, bpthread, string, base64, sys
from struct import pack, unpack from struct import pack, unpack
...@@ -895,55 +895,58 @@ class FileStorage(BaseStorage.BaseStorage): ...@@ -895,55 +895,58 @@ class FileStorage(BaseStorage.BaseStorage):
return r return r
def history(self, oid, version=None, length=1, filter=None): def history(self, oid, version=None, length=1, filter=None):
r=[] self._lock_acquire()
file=self._file try:
seek=file.seek r=[]
read=file.read file=self._file
pos=self._index[oid] seek=file.seek
wantver=version read=file.read
pos=self._index[oid]
wantver=version
while 1: while 1:
if len(r) >= length: return r if len(r) >= length: return r
seek(pos) seek(pos)
h=read(42) h=read(42)
doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h)
prev=u64(prev) prev=u64(prev)
if vlen: if vlen:
nv = read(8) != z64 nv = read(8) != z64
file.seek(8,1) # Skip previous version record pointer file.seek(8,1) # Skip previous version record pointer
version=read(vlen) version=read(vlen)
if wantver is not None and version != wantver: if wantver is not None and version != wantver:
if prev: if prev:
pos=prev pos=prev
continue continue
else: else:
return r return r
else: else:
version='' version=''
wantver=None wantver=None
seek(u64(tloc)) seek(u64(tloc))
h=read(23) h=read(23)
tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h)
if el < 0: el=t32-el if el < 0: el=t32-el
user_name=read(ul) user_name=read(ul)
description=read(dl) description=read(dl)
if el: d=loads(read(el)) if el: d=loads(read(el))
else: d={} else: d={}
d['time']=TimeStamp(serial).timeTime() d['time']=TimeStamp(serial).timeTime()
d['user_name']=user_name d['user_name']=user_name
d['description']=description d['description']=description
d['serial']=serial d['serial']=serial
d['version']=version d['version']=version
d['size']=u64(plen) d['size']=u64(plen)
if filter is None or filter(d): if filter is None or filter(d):
r.append(d) r.append(d)
if prev: pos=prev if prev: pos=prev
else: return r else: return r
finally: self._lock_release()
def pack(self, t, referencesf): def pack(self, t, referencesf):
......
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