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
df371d3f
Commit
df371d3f
authored
Nov 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
92002789
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+1
-1
wcfs/internal/wcfs_watchlink.cpp
wcfs/internal/wcfs_watchlink.cpp
+17
-10
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
df371d3f
...
...
@@ -167,7 +167,7 @@ error map_into(void *addr, size_t size, int prot, int flags, const os::File f, o
namespace
strings
{
bool
has_prefix
(
const
string
&
s
,
const
string
&
prefix
)
{
return
s
.
compare
(
0
,
prefix
.
size
(),
prefix
)
;
return
s
.
compare
(
0
,
prefix
.
size
(),
prefix
)
==
0
;
// XXX -> pygolang + tests
}
bool
has_prefix
(
const
string
&
s
,
char
prefix
)
{
...
...
wcfs/internal/wcfs_watchlink.cpp
View file @
df371d3f
...
...
@@ -61,7 +61,7 @@ pair<WatchLink, error> WCFS::_openwatch() {
tie
(
serveCtx
,
wlink
->
_serveCancel
)
=
context
::
with_cancel
(
context
::
background
());
wlink
->
_serveWG
=
sync
::
NewWorkGroup
(
serveCtx
);
wlink
->
_serveWG
->
go
([
wlink
](
context
::
Context
ctx
)
->
error
{
return
wlink
->
_serveRX
(
ctx
);
return
wlink
->
_serveRX
(
ctx
);
});
return
make_pair
(
wlink
,
nil
);
...
...
@@ -117,6 +117,7 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
// when finishing - wakeup everyone waiting for rx
defer
([
&
]()
{
printf
(
"serveRX: close all chans
\n
"
);
wlink
.
_acceptq
.
close
();
wlink
.
_rxmu
.
lock
();
wlink
.
_rxdown
=
true
;
// don't allow new rxtab registers
...
...
@@ -135,7 +136,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(" readline -> woken up; l='%s' ; err='%s'\n", l.c_str(), v(err));
printf
(
" readline -> woken up; l='%s' ; err='%s'
\n
"
,
l
.
c_str
(),
v
(
err
));
if
(
err
==
io
::
EOF_
)
{
// peer closed its tx
// XXX what happens on other errors?
wlink
.
_rx_eof
.
close
();
...
...
@@ -149,12 +150,12 @@ 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
"
,
v
(
err
));
printf
(
"line -> pkt: err='%s'
\n
"
,
v
(
err
));
if
(
err
!=
nil
)
return
err
;
printf
(
"pkt.stream: %lu
\n
"
,
pkt
.
stream
);
printf
(
"pkt.datalen: %u
\n
"
,
pkt
.
datalen
);
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 ?
...
...
@@ -181,7 +182,7 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
ctx
->
done
().
recvs
(),
// 0
rxq
.
sends
(
&
pkt
),
// 1
});
printf
(
"rxq <- pkt: -> sel #%d
\n
"
,
_
);
printf
(
"rxq <- pkt: -> sel #%d
\n
"
,
_
);
if
(
_
==
0
)
return
ctx
->
err
();
}
...
...
@@ -317,19 +318,25 @@ error _WatchLink::recvReq(context::Context ctx, PinReq *prx) {
if
(
!
ok
)
return
io
::
EOF_
;
pkt
.
to_string
();
//
pkt.to_string();
return
_parsePinReq
(
prx
,
&
pkt
);
}
// _parsePinReq parses message into PinReq according to wcfs invalidation protocol.
static
error
_parsePinReq
(
PinReq
*
pin
,
const
rxPkt
*
pkt
)
{
// XXX err ctx "bad pin"
printf
(
"parse pinreq: stream=%lu msg='%s'
\n
"
,
pkt
->
stream
,
&
pkt
->
data
[
0
]);
pin
->
stream
=
pkt
->
stream
;
auto
msg
=
pkt
->
to_string
();
string
msg
=
pkt
->
to_string
();
printf
(
"'%s'
\n
"
,
msg
.
c_str
());
printf
(
"has_prefix: %i
\n
"
,
strings
::
has_prefix
(
msg
,
"pin "
));
// pin <foid>) #<blk> @<at>
if
(
!
strings
::
has_prefix
(
msg
,
"pin "
))
if
(
!
strings
::
has_prefix
(
msg
,
"pin "
))
{
printf
(
"
\n\n\n
not a pin request: '%s'
\n
"
,
msg
.
c_str
());
// XXX temp
abort
();
return
fmt
::
errorf
(
"not a pin request: '%s'"
,
msg
.
c_str
());
// XXX msg -> errctx ?
}
auto
argv
=
strings
::
split
(
msg
.
substr
(
4
),
' '
);
if
(
argv
.
size
()
!=
3
)
...
...
@@ -371,7 +378,7 @@ 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());
//printf("\t_readline -> ret '%s'\n", line.c_str());
return
make_tuple
(
line
,
nil
);
}
nl_searchfrom
=
wlink
.
_rxbuf
.
length
();
...
...
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