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
2f24a37d
Commit
2f24a37d
authored
Oct 24, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
43c43472
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+22
-9
No files found.
wcfs/internal/wcfs_virtmem.cpp
View file @
2f24a37d
...
...
@@ -49,13 +49,22 @@ using namespace golang;
template
<
typename
Key
,
typename
Value
>
using
dict
=
std
::
unordered_map
<
Key
,
Value
>
;
struct
dict
:
std
::
unordered_map
<
Key
,
Value
>
{
// has returns whether container d (e.g. dict) has element k.
bool
has
(
const
Key
&
k
)
const
{
const
dict
*
d
=
this
;
return
d
->
find
(
k
)
!=
d
.
end
();
}
// has returns whether container d (e.g. dict) has element k.
template
<
typename
Container
,
typename
Key
>
bool
has
(
const
Container
&
d
,
Key
k
)
{
return
d
.
find
(
k
)
!=
d
.
end
();
}
// get implements `d[k] -> (v, ok)`.
tuple
<
Value
,
bool
>
get
(
const
Key
&
k
)
const
{
const
dict
*
d
=
this
;
auto
_
=
d
->
find
(
k
);
if
(
_
==
d
->
end
())
return
make_tuple
(
Value
(),
false
);
return
make_tuple
(
_
.
second
(),
true
);
}
};
template
<
typename
Key
>
using
set
=
std
::
unordered_set
<
Key
>
;
...
...
@@ -262,13 +271,17 @@ void Conn::_pin1(SrvReq *req) {
// XXX defer: reply either ack or nak on error
// XXX return error?
_File
*
f
;
bool
ok
;
wconn
->
_filemu
.
lock
();
if
(
has
(
wconn
->
_filetab
,
req
->
foid
))
{
tie
(
f
,
ok
)
=
wconn
->
_filetab
.
get
(
req
->
foid
);
//if (has(wconn->_filetab, req->foid)) {
if
(
!
ok
)
{
wconn
->
_filemu
.
unlock
();
// XXX err = we are not watching the file - why wcfs sent us this update?
}
_File
*
f
=
_
->
second
;
//
_File *f = _->second;
// XXX relock wconn -> f
...
...
@@ -372,7 +385,7 @@ tuple<WatchLink*, error> WCFS::_openwatch() {
wlink
->
_wc
=
wc
;
wlink
->
_f
=
f
;
wlink
->
_rx_eof
=
makechan
<
structZ
>
();
wlink
->
_acceptq
=
makechan
<
XXX
>
();
wlink
->
_acceptq
=
makechan
<
rxPkt
>
();
wlink
->
_req_next
=
1
;
wlink
->
_txclosed
=
false
;
...
...
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