Skip to content
Snippets Groups Projects
Commit 743930ce authored by pantianying's avatar pantianying
Browse files

fix bug

parent 3977bc6c
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ const (
var (
errNilZkClientConn = perrors.New("zookeeperclient{conn} is nil")
errNilChildren = perrors.Errorf("has none children")
errNilNode = perrors.Errorf("has none children")
)
// ZookeeperClient ...
......@@ -499,19 +500,24 @@ func (z *ZookeeperClient) GetChildrenW(path string) ([]string, <-chan zk.Event,
err = errNilZkClientConn
z.Lock()
if z.Conn != nil {
children, stat, event, err = z.Conn.ChildrenW(path)
}
conn := z.Conn
z.Unlock()
if conn != nil {
children, stat, event, err = conn.ChildrenW(path)
}
if err != nil {
if err == zk.ErrNoNode {
if err == zk.ErrNoChildrenForEphemerals {
return nil, nil, perrors.Errorf("path{%s} has none children", path)
}
if err == zk.ErrNoNode {
return nil, nil, errNilNode
}
logger.Errorf("zk.ChildrenW(path{%s}) = error(%v)", path, err)
return nil, nil, perrors.WithMessagef(err, "zk.ChildrenW(path:%s)", path)
}
if stat == nil {
return nil, nil, perrors.Errorf("path{%s} has none children", path)
return nil, nil, perrors.Errorf("path{%s} get stat is nil", path)
}
if len(children) == 0 {
return nil, nil, errNilChildren
......
......@@ -201,6 +201,11 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
}
}
l.client.RegisterEvent(zkPath, &event)
if err == errNilNode {
logger.Warnf("listenDirEvent(path{%s}) got errNilNode,so exit listen", zkPath)
l.client.UnregisterEvent(zkPath, &event)
return
}
select {
case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)):
l.client.UnregisterEvent(zkPath, &event)
......
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