VOL-1690: Don't close the event channel for watch events on the receiver.
Close it in the sender instead.
Change-Id: I0a2263440b7f7133365cb6054a620e9f25ae22dd
diff --git a/db/kvstore/etcdclient.go b/db/kvstore/etcdclient.go
index 1730173..88c13ae 100644
--- a/db/kvstore/etcdclient.go
+++ b/db/kvstore/etcdclient.go
@@ -393,7 +393,6 @@
if err := t.Close(); err != nil {
log.Errorw("watcher-cannot-be-closed", log.Fields{"key": key, "error": err})
}
- close(ch)
pos = i
break
}
@@ -410,6 +409,7 @@
func (c *EtcdClient) listenForKeyChange(channel v3Client.WatchChan, ch chan<- *Event, cancel context.CancelFunc) {
log.Debug("start-listening-on-channel ...")
defer cancel()
+ defer close(ch)
for resp := range channel {
for _, ev := range resp.Events {
//log.Debugf("%s %q : %q\n", ev.Type, ev.Kv.Key, ev.Kv.Value)