Skip to content

Commit

Permalink
Restore watches on authentication success
Browse files Browse the repository at this point in the history
  • Loading branch information
horkhe committed Sep 29, 2015
1 parent 167bc0f commit 03a78d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions zk/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ func (c *Conn) loop() {
wg.Done()
}()

c.sendSetWatches()
wg.Wait()
}

Expand Down Expand Up @@ -426,8 +427,6 @@ func (c *Conn) authenticate() error {
return err
}

c.sendSetWatches()

// connect response

// package length
Expand Down
2 changes: 2 additions & 0 deletions zk/zk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,12 @@ func TestSetWatchers(t *testing.T) {
t.Fatal("Children should return at least 1 child")
}

// Simulate network error by brutally closing the network connection.
zk.conn.Close()
if err := zk2.Delete(testPath, -1); err != nil && err != ErrNoNode {
t.Fatalf("Delete returned error: %+v", err)
}
// Allow some time for the `zk` session to reconnect and set watches.
time.Sleep(time.Millisecond * 100)

if path, err := zk2.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil {
Expand Down

0 comments on commit 03a78d2

Please sign in to comment.