Commit 1fde1d07 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0ff2cd10
...@@ -477,7 +477,16 @@ type Head struct { ...@@ -477,7 +477,16 @@ type Head struct {
type Watch struct { type Watch struct {
fsNode fsNode
// TODO // head/watch opens
// XXX protected by ... head.zconnMu ?
watchTab map[*Watcher]struct{}
}
// /head/watch handle - served by Watcher.
type Watcher struct {
sk *FileSock
// XXX
} }
// /(head|<rev>)/bigfile/ - served by BigFileDir. // /(head|<rev>)/bigfile/ - served by BigFileDir.
...@@ -580,7 +589,7 @@ func (_ *zodbCacheControl) PCacheClassify(obj zodb.IPersistent) zodb.PCachePolic ...@@ -580,7 +589,7 @@ func (_ *zodbCacheControl) PCacheClassify(obj zodb.IPersistent) zodb.PCachePolic
return 0 return 0
} }
func traceWatch(format string, argv ...interface{}) { func traceZWatch(format string, argv ...interface{}) {
if !log.V(1) { // XXX -> 2? if !log.V(1) { // XXX -> 2?
return return
} }
...@@ -595,7 +604,7 @@ func (root *Root) zwatcher(ctx context.Context) (err error) { ...@@ -595,7 +604,7 @@ func (root *Root) zwatcher(ctx context.Context) (err error) {
defer xerr.Contextf(&err, "zwatch") // XXX more in context? defer xerr.Contextf(&err, "zwatch") // XXX more in context?
// XXX unmount on error? -> always EIO? // XXX unmount on error? -> always EIO?
traceWatch(">>>") traceZWatch(">>>")
zwatchq := make(chan zodb.Event) zwatchq := make(chan zodb.Event)
at0 := root.zstor.AddWatch(zwatchq) // XXX -> to main thread to avoid race at0 := root.zstor.AddWatch(zwatchq) // XXX -> to main thread to avoid race
...@@ -606,22 +615,22 @@ func (root *Root) zwatcher(ctx context.Context) (err error) { ...@@ -606,22 +615,22 @@ func (root *Root) zwatcher(ctx context.Context) (err error) {
var ok bool var ok bool
for { for {
traceWatch("select ...") traceZWatch("select ...")
select { select {
case <-ctx.Done(): case <-ctx.Done():
traceWatch("cancel") traceZWatch("cancel")
return ctx.Err() return ctx.Err()
// TODO handle errors from ZODB watch stream // TODO handle errors from ZODB watch stream
case zevent, ok = <-zwatchq: case zevent, ok = <-zwatchq:
if !ok { if !ok {
traceWatch("zwatchq closed") traceZWatch("zwatchq closed")
return nil // closed XXX ok? return nil // closed XXX ok?
} }
} }
traceWatch("zevent: %s", zevent) traceZWatch("zevent: %s", zevent)
var *zodb.EventCommit var *zodb.EventCommit
switch zevent := zevent.(type) { switch zevent := zevent.(type) {
...@@ -1560,7 +1569,8 @@ func main() { ...@@ -1560,7 +1569,8 @@ func main() {
} }
watch := &Watch{ watch := &Watch{
fsNode: newFSNode(fSticky), fsNode: newFSNode(fSticky),
watchTab: make(map[*Watcher]struct{}),
} }
bfdir := &BigFileDir{ bfdir := &BigFileDir{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment