Merge pull request #325 from lavalamp/etcdChanFix

Don't double-close the channel when etcd returns an error.
This commit is contained in:
brendandburns 2014-07-01 13:46:50 -07:00
commit da61f90b08
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.