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
1b236e16
Commit
1b236e16
authored
Mar 10, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6ee3f42d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
wcfs/client/wcfs_watchlink.cpp
wcfs/client/wcfs_watchlink.cpp
+16
-7
wcfs/client/wcfs_watchlink.h
wcfs/client/wcfs_watchlink.h
+1
-0
No files found.
wcfs/client/wcfs_watchlink.cpp
View file @
1b236e16
...
...
@@ -67,14 +67,14 @@ pair<WatchLink, error> WCFS::_openwatch() {
}
error
_WatchLink
::
closeWrite
()
{
_WatchLink
&
wlink
=
*
this
;
_WatchLink
&
wlink
=
*
this
;
xerr
::
Contextf
E
(
"%s: closeWrite"
,
v
(
wlink
));
wlink
.
_txclose1
.
do_
([
&
]()
{
// ask wcfs to close its tx & rx sides; wcfs.close(tx) wakes up
// _serveRX on client (= on us). The connection can be already closed
// by wcfs - so ignore errors when sending bye.
(
void
)
wlink
.
_send
(
1
,
"bye"
);
// XXX stream ok?
(
void
)
wlink
.
_send
(
wlink
.
_nextReqID
(),
"bye"
);
// XXX vvv should be ~ shutdown(TX, wlink._f), however shutdown does
// not work for non-socket file descriptors. And even if we dup link
...
...
@@ -238,7 +238,7 @@ error _WatchLink::_write(const string &pkt) {
wlink
->
_txmu
.
unlock
();
});
//
printf
('C: watch : tx: %r' % pkt)
//
trace
('C: watch : tx: %r' % pkt)
int
n
;
error
err
;
tie
(
n
,
err
)
=
wlink
->
_f
->
write
(
pkt
.
c_str
(),
pkt
.
size
());
...
...
@@ -276,14 +276,23 @@ pair<string, error> _WatchLink::sendReq(context::Context ctx, const string &req)
return
make_pair
(
reply
,
nil
);
}
// _nextReqID returns stream ID for next client-originating request to be made.
// XXX place=?
StreamID
_WatchLink
::
_nextReqID
()
{
_WatchLink
&
wlink
=
*
this
;
wlink
.
_txmu
.
lock
();
// TODO ._req_next -> atomic (currently uses arbitrary lock)
StreamID
stream
=
wlink
.
_req_next
;
wlink
.
_req_next
=
(
wlink
.
_req_next
+
2
);
// wraparound at uint64 max
wlink
.
_txmu
.
unlock
();
return
stream
;
}
tuple
<
/*rxq*/
chan
<
rxPkt
>
,
error
>
_WatchLink
::
_sendReq
(
context
::
Context
ctx
,
const
string
&
req
)
{
_WatchLink
*
wlink
=
this
;
// XXX errctx?
wlink
->
_txmu
.
lock
();
// TODO ._req_next -> atomic (currently uses arbitrary lock)
StreamID
stream
=
wlink
->
_req_next
;
wlink
->
_req_next
=
(
wlink
->
_req_next
+
2
);
// wraparound at uint64 max
wlink
->
_txmu
.
unlock
();
StreamID
stream
=
wlink
->
_nextReqID
();
auto
rxq
=
makechan
<
rxPkt
>
(
1
);
wlink
->
_rxmu
.
lock
();
...
...
wcfs/client/wcfs_watchlink.h
View file @
1b236e16
...
...
@@ -118,6 +118,7 @@ private:
tuple
<
string
,
error
>
_readline
();
error
_send
(
StreamID
stream
,
const
string
&
msg
);
error
_write
(
const
string
&
pkt
);
StreamID
_nextReqID
();
tuple
<
chan
<
rxPkt
>
,
error
>
_sendReq
(
context
::
Context
ctx
,
const
string
&
req
);
friend
error
_twlinkwrite
(
WatchLink
wlink
,
const
string
&
pkt
);
...
...
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