Skip to content

Commit

Permalink
fix deadloop bug (#102)
Browse files Browse the repository at this point in the history
* fix deadloop bug

* revert import
  • Loading branch information
johnlanni authored Jul 19, 2022
1 parent 927aad2 commit 01d5bc0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion database/kv/zk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,17 @@ func NewMockZookeeperClient(name string, timeout time.Duration, opts ...Option)
// HandleZkEvent handles zookeeper events
func (d *DefaultHandler) HandleZkEvent(z *ZookeeperClient) {
var (
ok bool
state int
event zk.Event
)
for {
select {
case event = <-z.Session:
case event, ok = <-z.Session:
if !ok {
// channel already closed
return
}
switch event.State {
case zk.StateDisconnected:
atomic.StoreUint32(&z.valid, 0)
Expand Down

0 comments on commit 01d5bc0

Please sign in to comment.