Skip to content

Commit

Permalink
fix the set of events received by ChildrenW
Browse files Browse the repository at this point in the history
  • Loading branch information
sakateka authored and yarikk committed Dec 9, 2021
1 parent a87d7eb commit 90e39fa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ func (c *Conn) recvLoop(conn net.Conn) error {

if res.Xid == -1 {
res := &watcherEvent{}
_, err := decodePacket(buf[16:blen], res)
_, err = decodePacket(buf[16:blen], res)
if err != nil {
return err
}
Expand All @@ -816,15 +816,17 @@ func (c *Conn) recvLoop(conn net.Conn) error {
switch res.Type {
case EventNodeCreated:
wTypes = append(wTypes, watchTypeExist)
case EventNodeDeleted, EventNodeDataChanged:
wTypes = append(wTypes, watchTypeExist, watchTypeData, watchTypeChild)
case EventNodeDataChanged:
wTypes = append(wTypes, watchTypeExist, watchTypeData)
case EventNodeChildrenChanged:
wTypes = append(wTypes, watchTypeChild)
case EventNodeDeleted:
wTypes = append(wTypes, watchTypeExist, watchTypeData, watchTypeChild)
}
c.watchersLock.Lock()
for _, t := range wTypes {
wpt := watchPathType{res.Path, t}
if watchers := c.watchers[wpt]; watchers != nil && len(watchers) > 0 {
if watchers := c.watchers[wpt]; len(watchers) > 0 {
for _, ch := range watchers {
ch <- ev
close(ch)
Expand Down

0 comments on commit 90e39fa

Please sign in to comment.