Commit 9233294f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3af1ed43
...@@ -692,17 +692,11 @@ func traceZWatch(format string, argv ...interface{}) { ...@@ -692,17 +692,11 @@ func traceZWatch(format string, argv ...interface{}) {
// zwatcher watches for ZODB changes. // zwatcher watches for ZODB changes.
// //
// see "4) when we receive an invalidation message from ZODB ..." // see "4) when we receive an invalidation message from ZODB ..."
func (root *Root) zwatcher(ctx context.Context) (err error) { func (root *Root) zwatcher(ctx context.Context, zwatchq chan zodb.Event) (err error) {
defer xerr.Contextf(&err, "zwatch") // XXX more in context? defer xerr.Contextf(&err, "zwatch %s", root.zstor.URL())
// XXX unmount on error? -> always EIO? // XXX error -> always EIO for data operations
traceZWatch(">>>") traceZWatch(">>>")
zwatchq := make(chan zodb.Event)
at0 := root.zstor.AddWatch(zwatchq) // XXX -> to main thread to avoid race
defer root.zstor.DelWatch(zwatchq)
_ = at0 // XXX XXX
var zevent zodb.Event var zevent zodb.Event
var ok bool var ok bool
...@@ -2176,7 +2170,7 @@ func main() { ...@@ -2176,7 +2170,7 @@ func main() {
stdlog.SetFlags(stdlog.Lmicroseconds) stdlog.SetFlags(stdlog.Lmicroseconds)
} }
// open zodb storage/db/connection // open zodb storage/watch/db/connection
ctx := context.Background() // XXX + timeout? ctx := context.Background() // XXX + timeout?
zstor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ zstor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{
ReadOnly: true, ReadOnly: true,
...@@ -2186,9 +2180,15 @@ func main() { ...@@ -2186,9 +2180,15 @@ func main() {
} }
defer zstor.Close() defer zstor.Close()
zwatchq := make(chan zodb.Event)
at0 := zstor.AddWatch(zwatchq)
defer zstor.DelWatch(zwatchq)
zdb := zodb.NewDB(zstor) zdb := zodb.NewDB(zstor)
defer zdb.Close() // XXX err defer zdb.Close() // XXX err
zhead, err := zopen(ctx, zdb, &zodb.ConnOptions{ zhead, err := zopen(ctx, zdb, &zodb.ConnOptions{
At: at0,
// we need zhead.cache to be maintained across several transactions. // we need zhead.cache to be maintained across several transactions.
// see "3) for head/bigfile/* the following invariant is maintained ..." // see "3) for head/bigfile/* the following invariant is maintained ..."
NoPool: true, NoPool: true,
...@@ -2299,8 +2299,8 @@ func main() { ...@@ -2299,8 +2299,8 @@ func main() {
// XXX place = ok? // XXX place = ok?
// XXX ctx = ok? // XXX ctx = ok?
// XXX wait for zwatcher shutdown. // XXX wait for zwatcher shutdown + log from it error
go root.zwatcher(ctx) go root.zwatcher(ctx, zwatchq)
// TODO handle autoexit // TODO handle autoexit
// (exit when kernel forgets all our inodes - wcfs.py keeps .wcfs/zurl // (exit when kernel forgets all our inodes - wcfs.py keeps .wcfs/zurl
......
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