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
a4b30e86
Commit
a4b30e86
authored
Mar 31, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ca5e34cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
9 deletions
+35
-9
wcfs/wcfs.go
wcfs/wcfs.go
+35
-9
No files found.
wcfs/wcfs.go
View file @
a4b30e86
...
...
@@ -495,6 +495,7 @@ type Watcher struct {
// established file watchers.
// XXX in-progress - where? -> nowhere; here only established watches are added
// XXX locking?
// XXX -> {} foid -> FileWatch
fileTab
map
[
*
FileWatch
]
struct
{}
// IO
...
...
@@ -1239,9 +1240,8 @@ retry:
//
// XXX describe more.
// XXX explain that if rev ≤ .at there is no rev_next: rev < rev_next ≤ at.
// XXX error - when?
// XXX error - when?
or close watch on any error?
//
// XXX -> WatchFile.Pin(blk, at)
// XXX place=ok?
func
(
w
*
FileWatch
)
pin
(
ctx
context
.
Context
,
blk
int64
,
rev
zodb
.
Tid
)
(
err
error
)
{
foid
:=
w
.
file
.
zfile
.
POid
()
...
...
@@ -1275,6 +1275,35 @@ func (w *FileWatch) pin(ctx context.Context, blk int64, rev zodb.Tid) (err error
return
nil
}
// setupWatch sets up new FileWatch when client sends `watch <file> @<at>`.
//
// XXX place=ok?
func
(
watch
*
Watcher
)
setupWatch
(
ctx
context
.
Context
,
foid
zodb
.
Oid
,
at
zodb
.
Tid
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"setup watch f<%s> @%s"
,
foid
,
at
)
// XXX locking
// XXX at = zobd.InvalidTid - remove watch
// XXX if watch was already established - we need to update it
w
=
watch
.
fileTab
[
foid
]
if
w
!=
nil
{
// XXX update the watch
}
// watch was not previously established - set it up anew
// XXX locking
f
:=
watch
.
head
.
bfdir
.
fileTab
[
foid
]
if
f
==
nil
{
// by "invalidation protocol" watch is setup after data file was opened
return
fmt
.
Errorf
(
"file not yet known or is not a ZBigFile"
)
}
// XXX wait watch.head.zconn.At() ≥ at
}
// ---- Watch server ----
...
...
@@ -1344,18 +1373,15 @@ func (w *Watcher) _serveRX() (err error) {
continue
}
// client-initiated request
oid
,
at
,
err
:=
parseWatch
(
msg
)
// client-initiated
watch
request
f
oid
,
at
,
err
:=
parseWatch
(
msg
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"%d: %s"
,
stream
,
err
)
}
_
=
oid
_
=
at
_
,
err
=
fmt
.
Fprintf
(
w
.
sk
,
"%d error TODO
\n
"
,
stream
)
err
=
w
.
setupWatch
(
foid
,
at
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"%d: %s"
,
stream
,
err
)
}
}
}
...
...
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