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
12d448f0
Commit
12d448f0
authored
Mar 21, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3dbd5d75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
16 deletions
+42
-16
wcfs/wcfs.go
wcfs/wcfs.go
+41
-15
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+1
-1
No files found.
wcfs/wcfs.go
View file @
12d448f0
...
...
@@ -497,9 +497,9 @@ type Watcher struct {
fileTab
map
[
*
FileWatch
]
struct
{}
// IO
acceptq
chan
string
// (stream, msg) // client-initiated messages go here
//
acceptq chan string // (stream, msg) // client-initiated messages go here
rxMu
sync
.
Mutex
rxTab
map
[
uint32
]
chan
ms
g
// client replies go via here
rxTab
map
[
uint32
]
chan
strin
g
// client replies go via here
}
// FileWatch represents watching for 1 BigFile.
...
...
@@ -1250,7 +1250,7 @@ func (watch *Watch) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fuse.St
// XXX check flags?
w
:=
&
Watcher
{
sk
:
NewFileSock
(),
id
:
atomic
.
AddInt32
(
&
watch
.
id
,
+
1
)
id
:
atomic
.
AddInt32
(
&
watch
.
id
,
+
1
)
,
fileTab
:
make
(
map
[
*
FileWatch
]
struct
{}),
}
...
...
@@ -1286,32 +1286,58 @@ func (w *Watcher) _serve() (err error) {
fmt
.
Printf
(
"watch: rx: %q
\n
"
,
l
)
// <stream>
...
var
req
string
n
,
err
:=
fmt
.
Sscanf
(
l
,
"%d %s
\n
"
,
&
stream
,
&
req
)
if
err
==
nil
&&
n
!=
2
{
err
=
fmt
.
Errorf
(
"
invalid frame: %q"
,
l
)
// <stream>
<msg...>
sp
:=
strings
.
IndexByte
(
l
,
' '
)
if
sp
==
-
1
{
// XXX write to peer too? (on which stream? -1?)
return
fmt
.
Errorf
(
"rx:
invalid frame: %q"
,
l
)
}
stream
,
err
:=
strconv
.
ParseUint
(
l
[
:
sp
],
10
,
64
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"rx:
%s"
,
err
)
return
fmt
.
Errorf
(
"rx:
invalid frame (stream): %q"
,
l
)
}
msg
:=
l
[
sp
+
1
:
]
// reply from client to to wcfs
reply
:=
(
stream
%
2
==
0
)
// reply to wcfs message
if
reply
{
w
.
rxMu
.
Lock
()
rxq
:=
w
.
rxTab
[
stream
]
delete
(
w
.
rxTab
,
stream
)
w
.
rxMu
.
Unlock
()
if
rxq
==
nil
{
return
fmt
.
Errorf
(
"rx
: reply on unexpected stream %
d"
,
stream
)
return
fmt
.
Errorf
(
"rx
%d: reply on unexpected stream
d"
,
stream
)
}
rxq
<-
req
rxq
<-
msg
continue
}
// client-initiated message
}
else
{
fmt
.
Sscanf
(
req
,
"watch %s %s
\n
"
,
&
oid
,
&
ats
// client-initiated request
msg
=
strings
.
TrimSuffix
(
msg
,
"
\n
"
)
msgv
=
strings
.
Split
(
msg
,
" "
)
if
!
(
len
(
msgv
)
==
3
&&
msgv
[
0
]
!=
"watch"
)
{
// XXX write to peer too
return
fmt
.
Errorf
(
"rx %d: invalid request"
,
stream
)
}
oid
,
err
:=
zodb
.
ParseOid
(
msgv
[
1
])
if
err
!=
nil
{
return
fmt
.
Errorf
(
"rx %d: bad watch: invalid oid"
)
}
var
at
zodb
.
Tid
switch
{
case
msgv
[
2
]
==
"-"
:
at
=
zodb
.
InvalidTid
case
strings
.
HasPrefix
(
msgv
[
2
],
"@"
)
:
at
,
err
=
zodb
.
ParseTid
(
msgv
[
2
][
1
:
])
default
:
err
=
fmt
.
Errorf
(
"x"
)
// XXX just anything
}
if
err
!=
nil
{
return
fmt
.
Errorf
(
"rx %d: bad watch: invalid at"
)
}
}
...
...
wcfs/wcfs_test.py
View file @
12d448f0
...
...
@@ -408,7 +408,7 @@ class tWatch:
if
reply
:
with
t
.
_rxmu
:
assert
stream
in
t
.
_rxtab
rxq
=
t
.
_rxtab
s
[
stream
]
rxq
=
t
.
_rxtab
.
pop
(
stream
)
rxq
.
send
(
msg
)
else
:
with
t
.
_rxmu
:
...
...
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