Commit 14b40012 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 91592050
...@@ -498,14 +498,15 @@ class tFile: ...@@ -498,14 +498,15 @@ class tFile:
dataok += b'\0'*(t.blksize - len(dataok)) # tailing zeros dataok += b'\0'*(t.blksize - len(dataok)) # tailing zeros
assert blk < t._sizeinblk() assert blk < t._sizeinblk()
cached = f.cached()[blk] cached = t.cached()[blk]
shouldPin = False # whether at least one wlink should receive a pin
# watches must be notified if access goes to @head/file; not if to @rev/file. XXX text # watches must be notified if access goes to @head/file; not if to @rev/file. XXX text
wpin = {} # tWatchLink -> (zf, pinok) wpin = {} # tWatchLink -> (zf, pinok)
for wlink in t.tdb._wlinks: for wlink in t.tdb._wlinks:
pinok = {} pinok = {}
if t.at is None: # @head/... if t.at is None: # @head/...
wat = wlink._watching.get(zf) wat = wlink._watching.get(t.zf)
if wat is not None and wat < blkrev: if wat is not None and wat < blkrev:
if cached == 1: if cached == 1:
# XXX assert blk already pinned on that watch # XXX assert blk already pinned on that watch
...@@ -513,17 +514,18 @@ class tFile: ...@@ -513,17 +514,18 @@ class tFile:
else: else:
# XXX and watch not already pinned on the watch # XXX and watch not already pinned on the watch
pinok = {blk: t.tdb._blkRev(t.zf, blk, wat)} pinok = {blk: t.tdb._blkRev(t.zf, blk, wat)}
shouldPin = True
wpin[wlink] = (t.zf, pinok) wpin[wlink] = (t.zf, pinok)
if pinokByWLink is not None: if pinokByWLink is not None:
assert wpin == pinokByWLink, "computed vs explicit pinokByWLink" assert wpin == pinokByWLink, "computed vs explicit pinokByWLink"
pinokByWLink = wpin pinokByWLink = wpin
blkview = f.blk(blk) blkview = t.blk(blk)
assert f.cached()[blk] == cached assert t.cached()[blk] == cached
def _(ctx, ev): def _(ctx, ev):
assert f.cached()[blk] == cached assert t.cached()[blk] == cached
ev.append('read pre') ev.append('read pre')
# access data with released GIL so that the thread that reads data from # access data with released GIL so that the thread that reads data from
...@@ -552,9 +554,13 @@ class tFile: ...@@ -552,9 +554,13 @@ class tFile:
assert ev[0] == 'read pre' assert ev[0] == 'read pre'
assert ev[-1] == 'read ' + dataok[0] assert ev[-1] == 'read ' + dataok[0]
ev = ev[1:-1] ev = ev[1:-1]
# XXX ev == 'pin rx', 'pin ack pre' .... if not shouldPin:
assert ev == []
else:
assert 'pin rx' in ev
assert 'pin ack pre' in ev
assert f.cached()[blk] > 0 assert t.cached()[blk] > 0
# XXX assert individually for every block's page? (easier debugging?) # XXX assert individually for every block's page? (easier debugging?)
assert blkview == dataok, ("#blk: %d" % blk) assert blkview == dataok, ("#blk: %d" % blk)
...@@ -1143,7 +1149,7 @@ def test_wcfs(): ...@@ -1143,7 +1149,7 @@ def test_wcfs():
# XXX 5, {5: ø} # XXX 5, {5: ø}
# XXX 0, {0, at3} after δbtree works # XXX 0, {0, at3} after δbtree works
""" """
blk = 2 blk = 2
pinok = {2: at3} # XXX at3 -> at <= wl.at for zf pinok = {2: at3} # XXX at3 -> at <= wl.at for zf
...@@ -1180,7 +1186,7 @@ def test_wcfs(): ...@@ -1180,7 +1186,7 @@ def test_wcfs():
assert f.cached()[blk] > 0 assert f.cached()[blk] > 0
f.assertBlk(blk, '4c') f.assertBlk(blk, '4c')
assert f.cached()[blk] == 1 assert f.cached()[blk] == 1
""" """
wl.close() wl.close()
......
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