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
36d7ed95
Commit
36d7ed95
authored
Nov 21, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1947eb4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
wcfs/internal/_wcfs.pyx
wcfs/internal/_wcfs.pyx
+5
-0
wcfs/internal/wcfs_watchlink.cpp
wcfs/internal/wcfs_watchlink.cpp
+12
-5
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+5
-0
No files found.
wcfs/internal/_wcfs.pyx
View file @
36d7ed95
...
...
@@ -32,6 +32,8 @@ from libcpp.utility cimport pair
cdef
extern
from
*
:
ctypedef
bint
cbool
"bool"
from
libc.stdio
cimport
printf
# XXX temp
cdef
extern
from
"wcfs_watchlink.h"
nogil
:
cppclass
_WatchLink
:
error
close
()
...
...
@@ -90,9 +92,12 @@ cdef class PyWatchLink:
reply
=
_
.
first
err
=
_
.
second
printf
(
"pyxsendReq: reply='%s'
\
n
"
,
reply
.
c_str
())
if
err
!=
nil
:
raise
RuntimeError
(
err
.
Error
())
# XXX -> Xpy(err) ? pyraiseIf(err) ?
printf
(
"pyxsendReq: reply -> ok
\
n
"
)
return
reply
...
...
wcfs/internal/wcfs_watchlink.cpp
View file @
36d7ed95
...
...
@@ -124,7 +124,7 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
// NOTE: .close() makes sure .f.read*() will wake up
printf
(
"serveRX -> readline ...
\n
"
);
tie
(
l
,
err
)
=
wlink
.
_readline
();
// XXX +maxlen
printf
(
"
\t
readline -> woken up; l='%s' ; err='%s'
\n
"
,
l
.
c_str
(),
printf
(
"
readline -> woken up; l='%s' ; err='%s'
\n
"
,
l
.
c_str
(),
(
err
!=
nil
?
err
->
Error
().
c_str
()
:
"nil"
));
if
(
err
==
io
::
EOF_
)
{
// peer closed its tx
// XXX what happens on other errors?
...
...
@@ -135,9 +135,13 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
printf
(
"C: watch : rx: %s"
,
l
.
c_str
());
err
=
pkt
.
from_string
(
l
);
printf
(
"line -> pkt: err='%s'
\n
"
,
(
err
!=
nil
?
err
->
Error
().
c_str
()
:
"nil"
));
if
(
err
!=
nil
)
return
err
;
printf
(
"pkt.stream: %lu
\n
"
,
pkt
.
stream
);
printf
(
"pkt.datalen: %u
\n
"
,
pkt
.
datalen
);
if
(
pkt
.
stream
==
0
)
{
// control/fatal message from wcfs
// XXX print -> receive somewhere? XXX -> recvCtl ?
printf
(
"C: watch : rx fatal: %s
\n
"
,
l
.
c_str
());
...
...
@@ -163,6 +167,7 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
ctx
->
done
().
recvs
(),
// 0
rxq
.
sends
(
&
pkt
),
// 1
});
printf
(
"rxq <- pkt: -> sel #%d
\n
"
,
_
);
if
(
_
==
0
)
return
ctx
->
err
();
}
...
...
@@ -229,17 +234,18 @@ pair<string, error> _WatchLink::sendReq(context::Context ctx, const string &req)
if
(
err
!=
nil
)
return
make_pair
(
""
,
err
);
printf
(
"
\t
wait ...
\n
"
);
printf
(
"
sendReq:
wait ...
\n
"
);
int
_
=
select
({
ctx
->
done
().
recvs
(),
// 0
rxq
.
recvs
(
&
rx
),
// 1
});
printf
(
"
\t
woken up #%d
\n
"
,
_
);
printf
(
"
sendReq:
woken up #%d
\n
"
,
_
);
if
(
_
==
0
)
return
make_pair
(
""
,
ctx
->
err
());
// XXX check for EOF
string
reply
=
rx
.
to_string
();
printf
(
"sendReq: reply='%s'
\n
"
,
reply
.
c_str
());
return
make_pair
(
reply
,
nil
);
}
...
...
@@ -351,15 +357,16 @@ tuple<string, error> _WatchLink::_readline() {
if
(
nl
!=
string
::
npos
)
{
auto
line
=
wlink
.
_rxbuf
.
substr
(
0
,
nl
+
1
);
wlink
.
_rxbuf
=
wlink
.
_rxbuf
.
substr
(
nl
+
1
);
printf
(
"
\t
_readline -> ret '%s'
\n
"
,
line
.
c_str
());
return
make_tuple
(
line
,
nil
);
}
nl_searchfrom
=
wlink
.
_rxbuf
.
length
();
int
n
;
error
err
;
printf
(
"
_readline -> read ...
\n
"
);
printf
(
"
\t
_readline -> read ...
\n
"
);
tie
(
n
,
err
)
=
wlink
.
_f
->
read
(
buf
,
sizeof
(
buf
));
printf
(
"
_readline -> read: n=%d err='%s'
\n
"
,
n
,
(
err
!=
nil
?
err
->
Error
().
c_str
()
:
"nil"
));
printf
(
"
\t
_readline -> read: n=%d err='%s'
\n
"
,
n
,
(
err
!=
nil
?
err
->
Error
().
c_str
()
:
"nil"
));
if
(
n
>
0
)
{
// XXX limit line length to avoid DoS
wlink
.
_rxbuf
+=
string
(
buf
,
n
);
...
...
wcfs/wcfs_test.py
View file @
36d7ed95
...
...
@@ -1201,6 +1201,11 @@ def test_wcfs_watch_robust():
print
(
'
\
n
\
n
AAA'
)
wl
=
t
.
openwatch
()
print
(
'
\
n
\
n
BBB'
)
assert
"zzz"
==
"qqq"
print
(
'
\
n
\
n
\
n
alpha
\
n
\
n
\
n
'
)
x
=
wl
.
sendReq
(
timeout
(),
b"watch %s @%s"
%
(
h
(
zf
.
_p_oid
),
h
(
at1
)))
print
(
x
)
print
(
'
\
n
\
n
BBB 2'
)
assert
wl
.
sendReq
(
timeout
(),
b"watch %s @%s"
%
(
h
(
zf
.
_p_oid
),
h
(
at1
)))
==
\
"error setup watch f<%s> @%s: "
%
(
h
(
zf
.
_p_oid
),
h
(
at1
))
+
\
"file not yet known to wcfs or is not a ZBigFile"
...
...
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