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
3725aa97
Commit
3725aa97
authored
Mar 29, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e05f89b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
13 deletions
+41
-13
wcfs/wcfs.go
wcfs/wcfs.go
+41
-13
No files found.
wcfs/wcfs.go
View file @
3725aa97
...
...
@@ -493,7 +493,7 @@ type Watcher struct {
head
*
Head
// established file watchers.
// XXX in-progress - where?
// XXX in-progress - where?
-> nowhere; here only established watches are added
// XXX locking?
fileTab
map
[
*
FileWatch
]
struct
{}
...
...
@@ -1262,7 +1262,7 @@ func (w *FileWatch) pin(ctx context.Context, blk int64, rev zodb.Tid) (err error
// XXX comment
rev
,
_
=
w
.
file
.
δFtail
.
LastRevOf
(
blk
,
w
.
at
)
ack
,
err
:=
w
.
link
.
send
(
ctx
,
fmt
.
Sprintf
(
"pin %s #%s @%s"
,
foid
,
blk
,
rev
))
ack
,
err
:=
w
.
link
.
send
Req
(
ctx
,
fmt
.
Sprintf
(
"pin %s #%s @%s"
,
foid
,
blk
,
rev
))
if
err
!=
nil
{
return
err
}
...
...
@@ -1294,14 +1294,14 @@ func (watch *Watch) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fuse.St
// XXX del watchTab[w] on w.sk.File.Release
head
.
watchTab
[
w
]
=
struct
{}{}
go
w
.
serve
()
go
w
.
serve
RX
()
return
w
.
sk
.
File
(),
fuse
.
OK
}
// serve
serves client originated watch requests.
//
XXX serves rx? (-> and routes client replies ...)
func
(
w
*
Watcher
)
serve
()
{
err
:=
w
.
_serve
()
// serve
RX serves client originated watch requests and routes client replies to
//
wcfs originated requests.
func
(
w
*
Watcher
)
serve
RX
()
{
err
:=
w
.
_serve
RX
()
_
=
err
// XXX log error if !close
// XXX close if was not closed?
...
...
@@ -1309,15 +1309,15 @@ func (w *Watcher) serve() {
delete
(
w
.
head
.
watchTab
,
w
)
}
func
(
w
*
Watcher
)
_serve
()
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"watcher %d: serve"
,
w
.
id
)
func
(
w
*
Watcher
)
_serve
RX
()
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"watcher %d: serve
rx
"
,
w
.
id
)
r
:=
bufio
.
NewReader
(
w
.
sk
)
// XXX write to peer if it was logical error on client side
// XXX on which stream? -1?
for
{
l
,
err
:=
r
.
ReadString
(
'\n'
)
// XXX limit accepted line len
not to
DOS
l
,
err
:=
r
.
ReadString
(
'\n'
)
// XXX limit accepted line len
to prevent
DOS
if
err
!=
nil
{
return
err
}
...
...
@@ -1326,7 +1326,7 @@ func (w *Watcher) _serve() (err error) {
stream
,
msg
,
err
:=
parseWatchFrame
(
l
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
rx:
%s"
,
err
)
return
fmt
.
Errorf
(
"%s"
,
err
)
}
// reply from client to to wcfs
...
...
@@ -1338,7 +1338,7 @@ func (w *Watcher) _serve() (err error) {
w
.
rxMu
.
Unlock
()
if
rxq
==
nil
{
return
fmt
.
Errorf
(
"
rx
%d: reply on unexpected stream"
,
stream
)
return
fmt
.
Errorf
(
"%d: reply on unexpected stream"
,
stream
)
}
rxq
<-
msg
continue
...
...
@@ -1347,7 +1347,7 @@ func (w *Watcher) _serve() (err error) {
// client-initiated request
oid
,
at
,
err
:=
parseWatch
(
msg
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
rx
%d: %s"
,
stream
,
err
)
return
fmt
.
Errorf
(
"%d: %s"
,
stream
,
err
)
}
_
=
oid
...
...
@@ -1360,6 +1360,34 @@ func (w *Watcher) _serve() (err error) {
}
}
// sendReq sends wcfs-originated request to client and returns client response.
func
(
w
*
Watcher
)
sendReq
(
ctx
context
.
Context
,
req
string
)
(
reply
string
,
err
error
)
{
// XXX err ctx
// XXX assert '\n' not in req
stream
=
...
// XXX
rxq
:=
make
(
chan
string
)
// XXX cap=1? (so that if we return canceled we do not block client)
w
.
rxMu
.
Lock
()
w
.
rxTab
[
stream
]
=
rxq
// XXX assert .stream is not there?
w
.
rxMu
.
Unlock
()
// XXX lock tx
// XXX timeout write on ctx cancel
err
=
w
.
sk
.
Write
(
fmt
.
Sprintf
(
"%d %s
\n
"
,
stream
,
req
))
if
err
!=
nil
{
return
""
,
err
}
select
{
case
<-
ctx
.
Done
()
:
return
""
,
ctx
.
Err
()
case
reply
=
<-
rxq
:
return
reply
,
nil
}
}
// ---- Lookup ----
...
...
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