Commit 31eb89c3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2bd7052a
......@@ -425,7 +425,7 @@ class tFile:
t.assertCache([1]*len(datav))
# tWatch provides testing environment for /head/watch opened on wcfs.
# tWatch provides testing environment for /head/watch link opened on wcfs.
#
# .sendReq()/.recvReq() provides raw IO in terms of wcfs invalidation protocol messages.
# .watch() setups a watch for a file and verifies ... XXX
......@@ -486,24 +486,26 @@ class tWatch:
t.wtx.close()
t.wrx.close()
# wakeup everyone waiting for rx
t._acceptq.close()
with t._rxmu:
rxtab = t._rxtab
t._rxtab = None # don't allow new rxtab registers
for rxq in rxtab.values():
rxq.close()
# ---- message IO ----
# _serveRecv receives messages from .w and dispatches them according to streamID.
@func
def _serveRecv(t, ctx):
# when finishing - wakeup everyone waiting for rx
def _():
t._acceptq.close()
with t._rxmu:
rxtab = t._rxtab
t._rxtab = None # don't allow new rxtab registers
for rxq in rxtab.values():
rxq.close()
defer(_)
while 1:
# NOTE: .close() makes sure .wrx.read*() will wake up
l = t.wrx.readline()
#print('C: watch : rx: %r' % l)
print('C: watch : rx: %r' % l)
if len(l) == 0:
break # closed
......@@ -550,7 +552,7 @@ class tWatch:
# sendReq sends client -> server request and returns server reply.
#
# only 1 sendReq must be used at a time. # XXX relax?
def sendReq(t, ctx, req):
def sendReq(t, ctx, req): # reply | None when EOF
stream = 1
rxq = chan()
......@@ -843,6 +845,7 @@ def test_wcfs():
print('\n\n inv. protocol \n\n')
# XXX invalid requests -> wcfs replies error
# XXX -> separate test?
w = t.openwatch()
assert w.sendReq(context.background(), b'bla bla') == ""
# assert w closed
......
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