Commit 254cd177 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent eb78c5d2
...@@ -631,6 +631,8 @@ func parseWatchFrame(line string) (stream uint64, msg string, err error) { ...@@ -631,6 +631,8 @@ func parseWatchFrame(line string) (stream uint64, msg string, err error) {
// parseWatch parses watch request wcfs received over /head/watch. // parseWatch parses watch request wcfs received over /head/watch.
// //
// watch <file> (@<at>|-) // watch <file> (@<at>|-)
//
// at="-" is returned as zodb.InvalidTid .
func parseWatch(msg string) (oid zodb.Oid, at zodb.Tid, err error) { func parseWatch(msg string) (oid zodb.Oid, at zodb.Tid, err error) {
defer func() { defer func() {
if err != nil { if err != nil {
......
...@@ -1382,8 +1382,6 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T ...@@ -1382,8 +1382,6 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
// XXX locking // XXX locking
// XXX at = zobd.InvalidTid - remove watch
// XXX if watch was already established - we need to update it // XXX if watch was already established - we need to update it
w := wlink.byfile[foid] w := wlink.byfile[foid]
if w == nil { if w == nil {
...@@ -1404,6 +1402,15 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T ...@@ -1404,6 +1402,15 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
} }
// at=InvalidTid means "remove the watch"
// XXX locking
if at == zodb.InvalidTid {
delete(wlink.byfile, foid)
delete(w.file.watches, w)
return
}
// XXX check at >= w.at -> reject? // XXX check at >= w.at -> reject?
if !(at >= w.at) { if !(at >= w.at) {
panic("TODO") panic("TODO")
...@@ -1477,7 +1484,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T ...@@ -1477,7 +1484,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
return err return err
} }
// XXX locking // XXX locking, place = ok? or move closer to at==zodb.InvalidTid ^^^?
wlink.byfile[foid] = w wlink.byfile[foid] = w
return nil return nil
......
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