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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
f0744a6c
Commit
f0744a6c
authored
Jul 16, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
09bdef24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
56 deletions
+56
-56
wcfs/__init__.py
wcfs/__init__.py
+56
-1
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+0
-55
No files found.
wcfs/__init__.py
View file @
f0744a6c
...
...
@@ -38,7 +38,7 @@ import logging as log
from
os.path
import
dirname
from
errno
import
ENOENT
,
EEXIST
from
golang
import
chan
,
select
,
default
,
func
from
golang
import
chan
,
select
,
default
,
func
,
defer
from
golang
import
sync
,
context
from
golang.gcompat
import
qq
import
threading
...
...
@@ -151,6 +151,7 @@ class WatchLink(object):
# test code - we currently get stuck here.
#
# XXX -> better pthread_kill(SIGINT) instead of relying on wcfs proper behaviour?
# XXX -> we now have `kill -QUIT` to wcfs.go on test timeout - remove ^^^ comments?
try
:
wlink
.
_serveWG
.
wait
()
except
Exception
as
e
:
...
...
@@ -166,6 +167,60 @@ class WatchLink(object):
w
.
pinned
=
{}
wlink
.
_watching
=
{}
# _serveRX receives messages from ._wrx and dispatches them according to streamID.
@
func
def
_serveRX
(
wlink
,
ctx
):
# when finishing - wakeup everyone waiting for rx
def
_
():
wlink
.
_acceptq
.
close
()
with
wlink
.
_rxmu
:
rxtab
=
wlink
.
_rxtab
wlink
.
_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
=
wlink
.
_wrx
.
readline
()
print
(
'C: watch : rx: %r'
%
l
)
if
len
(
l
)
==
0
:
# peer closed its tx
wlink
.
rx_eof
.
close
()
break
# <stream> ... \n
stream
,
msg
=
l
.
split
(
' '
,
1
)
stream
=
int
(
stream
)
msg
=
msg
.
rstrip
(
'
\
n
'
)
if
stream
==
0
:
# control/fatal message from wcfs
# XXX print -> receive somewhere?
print
(
'C: watch : rx fatal: %r'
%
msg
)
wlink
.
fatalv
.
append
(
msg
)
continue
reply
=
bool
(
stream
%
2
)
if
reply
:
with
wlink
.
_rxmu
:
assert
stream
in
wlink
.
_rxtab
# XXX !test assert - recheck
rxq
=
wlink
.
_rxtab
.
pop
(
stream
)
_
,
_rx
=
select
(
ctx
.
done
().
recv
,
# 0
(
rxq
.
send
,
msg
),
# 1
)
if
_
==
0
:
raise
ctx
.
err
()
else
:
with
wlink
.
_rxmu
:
assert
stream
not
in
wlink
.
_accepted
# XXX !test assert - recheck
wlink
.
_accepted
.
add
(
stream
)
_
,
_rx
=
select
(
ctx
.
done
().
recv
,
# 0
(
wlink
.
_acceptq
.
send
,
(
stream
,
msg
)),
# 1
)
if
_
==
0
:
raise
ctx
.
err
()
# ---- WCFS raw file access ----
...
...
wcfs/wcfs_test.py
View file @
f0744a6c
...
...
@@ -719,7 +719,6 @@ class tWatch:
# tWatchLink provides testing environment for /head/watch link opened on wcfs.
#
# .sendReq()/.recvReq() provides raw IO in terms of wcfs invalidation protocol messages. XXX kill here?
# .watch() setups/adjusts a watch for a file and verifies that wcfs correctly sends initial pins.
class
tWatchLink
(
wcfs
.
WatchLink
):
...
...
@@ -735,60 +734,6 @@ class tWatchLink(wcfs.WatchLink):
# ---- message IO ----
# _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
.
_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
)
if
len
(
l
)
==
0
:
# peer closed its tx
t
.
rx_eof
.
close
()
break
# <stream> ... \n
stream
,
msg
=
l
.
split
(
' '
,
1
)
stream
=
int
(
stream
)
msg
=
msg
.
rstrip
(
'
\
n
'
)
if
stream
==
0
:
# control/fatal message from wcfs
# XXX print -> receive somewhere?
print
(
'C: watch : rx fatal: %r'
%
msg
)
t
.
fatalv
.
append
(
msg
)
continue
reply
=
bool
(
stream
%
2
)
if
reply
:
with
t
.
_rxmu
:
assert
stream
in
t
.
_rxtab
rxq
=
t
.
_rxtab
.
pop
(
stream
)
_
,
_rx
=
select
(
ctx
.
done
().
recv
,
# 0
(
rxq
.
send
,
msg
),
# 1
)
if
_
==
0
:
raise
ctx
.
err
()
else
:
with
t
.
_rxmu
:
assert
stream
not
in
t
.
_accepted
t
.
_accepted
.
add
(
stream
)
_
,
_rx
=
select
(
ctx
.
done
().
recv
,
# 0
(
t
.
_acceptq
.
send
,
(
stream
,
msg
)),
# 1
)
if
_
==
0
:
raise
ctx
.
err
()
# _send sends raw message via specified stream.
#
...
...
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