Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
23d34fb0
Commit
23d34fb0
authored
Jun 05, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
16371832
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+23
-12
No files found.
wcfs/wcfs_test.py
View file @
23d34fb0
...
...
@@ -474,8 +474,11 @@ class tWatchLink:
# object is closed -> dup fd so that each file object has its own fd.
wh
=
os
.
open
(
tdb
.
path
(
"head/watch"
),
os
.
O_RDWR
)
wh2
=
os
.
dup
(
wh
)
t
.
wrx
=
os
.
fdopen
(
wh
,
'rb'
)
t
.
wtx
=
os
.
fdopen
(
wh2
,
'wb'
)
t
.
_wrx
=
os
.
fdopen
(
wh
,
'rb'
)
t
.
_wtx
=
os
.
fdopen
(
wh2
,
'wb'
)
# .rx_eof becomes ready when wcfs closes its tx side
t
.
rx_eof
=
chan
()
# inv.protocol message IO
t
.
_acceptq
=
chan
()
# (stream, msg) server originated messages go here
...
...
@@ -513,17 +516,18 @@ class tWatchLink:
if
e
!=
context
.
canceled
:
reraise
(
e
,
None
,
e
.
__traceback__
)
t
.
wtx
.
close
()
t
.
wrx
.
close
()
t
.
_
wtx
.
close
()
t
.
_
wrx
.
close
()
# ---- message IO ----
# _serveRX receives messages from .wrx and dispatches them according to streamID.
# _serveRX receives messages from .
_
wrx and dispatches them according to streamID.
@
func
def
_serveRX
(
t
,
ctx
):
# when finishing - wakeup everyone waiting for rx
def
_
():
t
.
rx_eof
.
close
()
t
.
_acceptq
.
close
()
with
t
.
_rxmu
:
rxtab
=
t
.
_rxtab
...
...
@@ -533,8 +537,8 @@ class tWatchLink:
defer
(
_
)
while
1
:
# NOTE: .close() makes sure .wrx.read*() will wake up
l
=
t
.
wrx
.
readline
()
# NOTE: .close() makes sure .
_
wrx.read*() will wake up
l
=
t
.
_
wrx
.
readline
()
print
(
'C: watch : rx: %r'
%
l
)
if
len
(
l
)
==
0
:
break
# closed
...
...
@@ -576,8 +580,8 @@ class tWatchLink:
with
t
.
_txmu
:
pkt
=
b"%d %s
\
n
"
%
(
stream
,
msg
)
#print('C: watch : tx: %r' % pkt)
t
.
wtx
.
write
(
pkt
)
t
.
wtx
.
flush
()
t
.
_
wtx
.
write
(
pkt
)
t
.
_
wtx
.
flush
()
# sendReq sends client -> server request and returns server reply.
#
...
...
@@ -873,13 +877,20 @@ def test_wcfs():
# >>> invalidation protocol
print
(
'
\
n
\
n
inv. protocol
\
n
\
n
'
)
# XXX invalid requests -> wcfs replies error
# XXX -> separate test?
# invalid requests -> wcfs replies error
wl
=
t
.
openwatch
()
assert
wl
.
sendReq
(
context
.
background
(),
b'bla bla'
)
==
b"error bad watch: not a watch request"
# XXX assert wl closed
# wcfs must close watch link after invalid request
_
,
_rx
=
select
(
time
.
after
(
3
*
time
.
second
).
recv
,
wl
.
rx_eof
.
recv
,
)
if
_
==
0
:
raise
RuntimeError
(
"%s: did not rx EOF after invalid watch request"
%
wl
)
wl
.
close
()
return
for
zf
in
t
.
zfiles
():
# watch going at_i -> at_j -> ...
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment