Commit 4e8c3489 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cac15697
...@@ -533,6 +533,8 @@ func (root *Root) zwatcher(ctx context.Context) (err error) { ...@@ -533,6 +533,8 @@ 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?
log.Info("ZWatcher ...")
zwatchq := make(chan zodb.CommitEvent) zwatchq := make(chan zodb.CommitEvent)
root.zstor.AddWatch(zwatchq) root.zstor.AddWatch(zwatchq)
defer root.zstor.DelWatch(zwatchq) defer root.zstor.DelWatch(zwatchq)
...@@ -541,11 +543,15 @@ func (root *Root) zwatcher(ctx context.Context) (err error) { ...@@ -541,11 +543,15 @@ func (root *Root) zwatcher(ctx context.Context) (err error) {
var ok bool var ok bool
for { for {
log.Info(".")
select { select {
case <-ctx.Done(): case <-ctx.Done():
log.Info("cancel")
return ctx.Err() return ctx.Err()
case zevent, ok = <-zwatchq: case zevent, ok = <-zwatchq:
log.Info("event")
if !ok { if !ok {
return nil // closed XXX ok? return nil // closed XXX ok?
} }
...@@ -557,6 +563,7 @@ func (root *Root) zwatcher(ctx context.Context) (err error) { ...@@ -557,6 +563,7 @@ func (root *Root) zwatcher(ctx context.Context) (err error) {
// zhandle1 handles 1 event from ZODB notification. // zhandle1 handles 1 event from ZODB notification.
func (root *Root) zhandle1(zevent zodb.CommitEvent) { func (root *Root) zhandle1(zevent zodb.CommitEvent) {
log.Infof("zwatcher: handle: %s", zevent)
// while we are invalidating OS cache, make sure that nothing, that // while we are invalidating OS cache, make sure that nothing, that
// even reads /head/bigfile/*, is running (see 4.6). // even reads /head/bigfile/*, is running (see 4.6).
root.head.zconnMu.Lock() root.head.zconnMu.Lock()
...@@ -1287,6 +1294,11 @@ func main() { ...@@ -1287,6 +1294,11 @@ func main() {
Node: newDefaultNode(), Node: newDefaultNode(),
}) })
// XXX place = ok?
// XXX ctx = ok?
// XXX wait for zwatcher shutdown.
go root.zwatcher(ctx)
// TODO handle autoexit // TODO handle autoexit
_ = autoexit _ = autoexit
......
...@@ -168,6 +168,7 @@ def test_wcfs(): ...@@ -168,6 +168,7 @@ def test_wcfs():
Z = _() Z = _()
Z.tidv = [] Z.tidv = []
def commit(): def commit():
print 'commit'
last._p_changed = 1 last._p_changed = 1
transaction.commit() transaction.commit()
tid = last._p_serial tid = last._p_serial
......
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