Commit 508a3d71 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0a125d3c
......@@ -532,7 +532,7 @@ class tFile:
assert wpin == pinokByWLink, "computed vs explicit pinokByWLink"
pinokByWLink = wpin
# doCheckingPin expect every wlink entry to also contain zf
# doCheckingPin expects every wlink entry to also contain zf
for wlink, pinok in pinokByWLink.items():
pinokByWLink[wlink] = (t.zf, pinok)
......@@ -606,7 +606,7 @@ class tFile:
# tWatch represents watch for one file setup on a tWatchLink.
class tWatch:
def __init__(w):
w.at = None # None only initially - always concrete after setup
w.at = z64 # not None - always concrete
w.pinned = {} # blk -> rev
# tWatchLink provides testing environment for /head/watch link opened on wcfs.
......@@ -876,9 +876,11 @@ def watch(twlink, zf, at, pinok=None): # XXX -> ?
t = twlink.tdb
w = twlink._watching.get(zf)
if w is None:
w = tWatch()
w = twlink._watching[zf] = tWatch()
at_prev = None
else:
at_prev = w.at # we were previously watching zf @at_prev
at_prev = w.at # we were previously watching zf @at_prev
at_from = ''
if at_prev is not None:
at_from = '(%s ->) ' % t.hat(at_prev)
......@@ -939,7 +941,6 @@ def watch(twlink, zf, at, pinok=None): # XXX -> ?
w.at = at
# XXX update pinned
twlink._watching[zf] = w
# _watch sends watch request for zf@at, expects initial pins specified by pinok and final reply.
#
......@@ -979,7 +980,11 @@ def doCheckingPin(f, pinokByWLink, pinfunc=None): # -> []event(str)
ev = []
for wlink, (zf, pinok) in pinokByWLink.items():
def _(ctx, wlink):
def _(ctx, wlink, zf, pinok):
w = wlink._watching.get(zf)
if len(pinok) > 0:
assert w is not None
pinv = wlink._expectPin(ctx, zf, pinok)
if len(pinv) > 0:
ev.append('pin rx') # XXX + zf, pin details?
......@@ -993,6 +998,13 @@ def doCheckingPin(f, pinokByWLink, pinfunc=None): # -> []event(str)
pinfunc(wlink, p.foid, p.blk, p.at)
ev.append('pin ack pre') # XXX +details?
for p in pinv:
assert w.foid == p.foid
if p.at is None: # repin to @head
assert p.blk in w.pinned # must have been pinned before XXX correct?
del w.pinned[p.blk]
else:
w.pinned[p.blk] = p.at
p.reply(b"ack")
# check that we don't get extra pins before f completes
......@@ -1004,7 +1016,7 @@ def doCheckingPin(f, pinokByWLink, pinfunc=None): # -> []event(str)
reraise(e, None, e.__traceback__)
assert False, "extra pin message received: %r" % req.msg
wg.go(_, wlink)
wg.go(_, wlink, zf, pinok)
def _(ctx):
f(ctx, ev)
......
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