Don't double-close the channel when etcd returns an error.

This commit is contained in:
Daniel Smith 2014-07-01 12:37:35 -07:00
parent a10ac51224
commit 229b8fca2a
2 changed files with 5 additions and 4 deletions

View File

@ -105,11 +105,10 @@ func (rm *ReplicationManager) watchControllers() {
}()
go func() {
defer util.HandleCrash()
defer func() {
close(watchChannel)
}()
_, err := rm.etcdClient.Watch("/registry/controllers", 0, true, watchChannel, stop)
if err != etcd.ErrWatchStoppedByUser {
if err == etcd.ErrWatchStoppedByUser {
close(watchChannel)
} else {
glog.Errorf("etcd.Watch stopped unexpectedly: %v (%#v)", err, err)
}
}()

View File

@ -135,6 +135,8 @@ func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool,
case <-stop:
return nil, etcd.ErrWatchStoppedByUser
case err := <-injectedError:
// Emulate etcd's behavior.
close(receiver)
return nil, err
}
// Never get here.