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
5d0a19af
Commit
5d0a19af
authored
Jun 06, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6b0fddc2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
wcfs/wcfs.go
wcfs/wcfs.go
+1
-3
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+13
-8
No files found.
wcfs/wcfs.go
View file @
5d0a19af
...
...
@@ -1608,13 +1608,11 @@ func (wlink *WatchLink) _serve() (err error) {
func
(
wlink
*
WatchLink
)
handleWatch
(
ctx
context
.
Context
,
stream
uint64
,
msg
string
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%d"
,
stream
)
// FIXME error "at is too far away" from setupWatch shuold be not fatal
// (XXX bad parse watch -> fatal (not following protocol))
// XXX kill fatal replies? (i.e. make almost everything non-fatal ?)
err
=
wlink
.
_handleWatch
(
ctx
,
msg
)
reply
:=
"ok"
if
err
!=
nil
{
reply
=
fmt
.
Sprintf
(
"error %s"
,
err
)
err
=
nil
}
err2
:=
wlink
.
send
(
ctx
,
stream
,
reply
)
...
...
wcfs/wcfs_test.py
View file @
5d0a19af
...
...
@@ -477,8 +477,8 @@ class tWatchLink:
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
()
t
.
rx_eof
=
chan
()
# .rx_eof becomes ready when wcfs closes its tx side
t
.
fatalv
=
[]
# fatal messages go here
# inv.protocol message IO
t
.
_acceptq
=
chan
()
# (stream, msg) server originated messages go here
...
...
@@ -555,6 +555,7 @@ class tWatchLink:
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
)
...
...
@@ -586,8 +587,11 @@ class tWatchLink:
# XXX +ctx?
def
_send
(
t
,
stream
,
msg
):
assert
'
\
n
'
not
in
msg
pkt
=
b"%d %s
\
n
"
%
(
stream
,
msg
)
t
.
_write
(
pkt
)
def
_write
(
t
,
pkt
):
with
t
.
_txmu
:
pkt
=
b"%d %s
\
n
"
%
(
stream
,
msg
)
#print('C: watch : tx: %r' % pkt)
t
.
_wtx
.
write
(
pkt
)
t
.
_wtx
.
flush
()
...
...
@@ -886,21 +890,22 @@ def test_wcfs():
# >>> invalidation protocol
print
(
'
\
n
\
n
inv. protocol
\
n
\
n
'
)
# invalid requests -> wcfs replies error
# XXX invalid request not following frame structure `<stream> ...`
# invalid requests -> wcfs replies error
wl
=
t
.
openwatch
()
assert
wl
.
sendReq
(
context
.
background
(),
b'bla bla'
)
==
\
b'error bad watch: not a watch request: "bla bla"'
# wcfs must close watch link after invalid request
# invalid request not following frame structure -> fatal + wcfs must close watch link
assert
wl
.
fatalv
==
[]
wl
.
_write
(
b'zzz hello
\
n
'
)
_
,
_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
)
raise
RuntimeError
(
"%s: did not rx EOF after bad frame "
%
wl
)
assert
wl
.
fatalv
==
[]
# XXX
wl
.
close
()
return
...
...
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