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

.

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