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
1519b8ae
Commit
1519b8ae
authored
Mar 10, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5beec283
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
wcfs/client/wcfs_watchlink.cpp
wcfs/client/wcfs_watchlink.cpp
+10
-7
No files found.
wcfs/client/wcfs_watchlink.cpp
View file @
1519b8ae
...
@@ -28,6 +28,14 @@
...
@@ -28,6 +28,14 @@
#include <string.h>
#include <string.h>
#define TRACE 0
#if TRACE
# define trace(format, ...) log::Debugf(format, ##__VA_ARGS__)
#else
# define trace(format, ...) do {} while (0)
#endif
// wcfs::
// wcfs::
namespace
wcfs
{
namespace
wcfs
{
...
@@ -120,7 +128,6 @@ error _WatchLink::_serveRX(context::Context ctx) {
...
@@ -120,7 +128,6 @@ error _WatchLink::_serveRX(context::Context ctx) {
// when finishing - wakeup everyone waiting for rx
// when finishing - wakeup everyone waiting for rx
defer
([
&
]()
{
defer
([
&
]()
{
//trace("serveRX: close all chans\n");
wlink
.
_acceptq
.
close
();
wlink
.
_acceptq
.
close
();
wlink
.
_rxmu
.
lock
();
wlink
.
_rxmu
.
lock
();
wlink
.
_rxdown
=
true
;
// don't allow new rxtab registers
wlink
.
_rxdown
=
true
;
// don't allow new rxtab registers
...
@@ -138,7 +145,6 @@ error _WatchLink::_serveRX(context::Context ctx) {
...
@@ -138,7 +145,6 @@ error _WatchLink::_serveRX(context::Context ctx) {
while
(
1
)
{
while
(
1
)
{
// NOTE: .close() makes sure .f.read*() will wake up
// NOTE: .close() makes sure .f.read*() will wake up
tie
(
l
,
err
)
=
wlink
.
_readline
();
tie
(
l
,
err
)
=
wlink
.
_readline
();
//trace(" readline -> l='%s' ; err='%s'\n", v(l), v(err));
if
(
err
==
io
::
EOF_
)
{
// peer closed its tx
if
(
err
==
io
::
EOF_
)
{
// peer closed its tx
// XXX what happens on other errors?
// XXX what happens on other errors?
wlink
.
rx_eof
.
close
();
wlink
.
rx_eof
.
close
();
...
@@ -149,7 +155,7 @@ error _WatchLink::_serveRX(context::Context ctx) {
...
@@ -149,7 +155,7 @@ error _WatchLink::_serveRX(context::Context ctx) {
err
=
nil
;
err
=
nil
;
return
E
(
err
);
return
E
(
err
);
}
}
//
trace("C: watch : rx: \"%s\"", v(l));
trace
(
"C: watch : rx:
\"
%s
\"
"
,
v
(
l
));
err
=
pkt
.
from_string
(
l
);
err
=
pkt
.
from_string
(
l
);
if
(
err
!=
nil
)
if
(
err
!=
nil
)
...
@@ -347,7 +353,7 @@ error _WatchLink::_write(const string &pkt) {
...
@@ -347,7 +353,7 @@ error _WatchLink::_write(const string &pkt) {
wlink
.
_txmu
.
unlock
();
wlink
.
_txmu
.
unlock
();
});
});
//trace('C: watch : tx: \"%s\"'
, v(pkt));
trace
(
"C: watch : tx:
\"
%s
\"
"
,
v
(
pkt
));
int
n
;
int
n
;
error
err
;
error
err
;
tie
(
n
,
err
)
=
wlink
.
_f
->
write
(
pkt
.
c_str
(),
pkt
.
size
());
tie
(
n
,
err
)
=
wlink
.
_f
->
write
(
pkt
.
c_str
(),
pkt
.
size
());
...
@@ -408,7 +414,6 @@ tuple<string, error> _WatchLink::_readline() {
...
@@ -408,7 +414,6 @@ tuple<string, error> _WatchLink::_readline() {
if
(
nl
!=
string
::
npos
)
{
if
(
nl
!=
string
::
npos
)
{
auto
line
=
wlink
.
_rxbuf
.
substr
(
0
,
nl
+
1
);
auto
line
=
wlink
.
_rxbuf
.
substr
(
0
,
nl
+
1
);
wlink
.
_rxbuf
=
wlink
.
_rxbuf
.
substr
(
nl
+
1
);
wlink
.
_rxbuf
=
wlink
.
_rxbuf
.
substr
(
nl
+
1
);
//trace("\t_readline -> ret '%s'\n", v(line));
return
make_tuple
(
line
,
nil
);
return
make_tuple
(
line
,
nil
);
}
}
nl_searchfrom
=
wlink
.
_rxbuf
.
length
();
nl_searchfrom
=
wlink
.
_rxbuf
.
length
();
...
@@ -419,9 +424,7 @@ tuple<string, error> _WatchLink::_readline() {
...
@@ -419,9 +424,7 @@ tuple<string, error> _WatchLink::_readline() {
int
n
;
int
n
;
error
err
;
error
err
;
//trace("\t_readline -> read ...\n");
tie
(
n
,
err
)
=
wlink
.
_f
->
read
(
buf
,
sizeof
(
buf
));
tie
(
n
,
err
)
=
wlink
.
_f
->
read
(
buf
,
sizeof
(
buf
));
//trace("\t_readline -> read: n=%d err='%s'\n", n, v(err));
if
(
n
>
0
)
{
if
(
n
>
0
)
{
wlink
.
_rxbuf
+=
string
(
buf
,
n
);
wlink
.
_rxbuf
+=
string
(
buf
,
n
);
continue
;
continue
;
...
...
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