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
5c02054e
Commit
5c02054e
authored
Oct 28, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
350027d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+2
-1
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+1
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+39
-4
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
5c02054e
...
...
@@ -35,7 +35,8 @@ using namespace golang;
// io::
namespace
io
{
const
error
EOF_
=
fmt
::
errorf
(
"EOF"
);
const
error
EOF_
=
fmt
::
errorf
(
"EOF"
);
const
error
ErrUnexpectedEOF
=
fmt
::
errorf
(
"unexpected EOF"
);
}
// io::
...
...
wcfs/internal/wcfs_misc.h
View file @
5c02054e
...
...
@@ -51,6 +51,7 @@ struct error {
namespace
io
{
extern
const
error
EOF_
;
extern
const
error
ErrUnexpectedEOF
;
}
// io::
...
...
wcfs/internal/wcfs_virtmem.cpp
View file @
5c02054e
...
...
@@ -209,6 +209,7 @@ public:
private:
void
_closeTX
();
error
_serveRX
(
IContext
*
ctx
);
tuple
<
string
,
error
>
_readline
();
error
_send
(
StreamID
stream
,
const
string
&
msg
);
error
_write
(
const
string
&
pkt
);
tuple
<
chan
<
rxPkt
>
,
error
>
_sendReq
(
IContext
*
ctx
,
const
string
&
req
);
...
...
@@ -467,14 +468,19 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ?
}
});
string
l
;
error
err
;
while
(
1
)
{
// NOTE: .close() makes sure .f.read*() will wake up
l
=
wlink
.
_f
.
readline
()
printf
(
"C: watch : rx: %r"
%
l
);
if
(
len
(
l
)
==
0
)
{
// peer closed its tx
tie
(
l
,
err
)
=
wlink
.
_readline
();
if
(
err
==
io
::
EOF_
)
{
// peer closed its tx
// XXX what happens with other errors?
wlink
.
_rx_eof
.
close
();
break
;
}
if
(
err
!=
nil
)
return
err
;
printf
(
"C: watch : rx: %s"
,
l
.
c_str
());
// <stream> ... \n
stream
,
msg
=
l
.
split
(
' '
,
1
)
...
...
@@ -618,6 +624,35 @@ tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(IContext *ctx, const string
return
make_tuple
(
rxq
,
err
);
}
// _readline reads next raw line sent from wcfs.
tuple
<
string
,
error
>
WatchLink
::
_readline
()
{
WatchLink
&
wlink
=
*
this
;
char
buf
[
128
];
pos
=
0
;
// XXX naming
while
(
1
)
{
nl
=
wlink
.
_rxbuf
.
find
(
'\n'
,
pos
);
if
(
nl
!=
string
::
npos
)
{
line
=
string
(
wlink
.
_rxbuf
,
0
,
nl
+
1
);
wlink
.
_rxbuf
=
string
(
wlink
.
_rxbuf
,
nl
+
1
);
return
make_tuple
(
line
,
nil
);
}
pos
=
wlink
.
_rxbuf
.
length
();
tie
(
n
,
err
)
=
wlink
.
_f
.
read
(
buf
,
sizeof
(
buf
));
if
(
n
>
0
)
{
// XXX limit line length to avoid DoS
wlink
.
_rxbuf
+=
string
(
buf
,
n
);
continue
;
}
if
(
err
==
nil
)
panic
(
"read returned (0, nil)"
);
if
(
err
==
io
::
EOF_
&&
wlink
.
_rxbuf
.
length
()
!=
0
)
err
=
io
::
ErrUnexpectedEOF
;
return
make_tuple
(
""
,
err
);
}
}
// ---- WCFS raw file access ----
// _path returns path for object on wcfs.
...
...
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