Fix send on closed channel bug

Signed-off-by: Chun Chen <chenchun.feed@gmail.com>
This commit is contained in:
Chun Chen 2015-06-12 15:42:34 +08:00
parent e10c7b3f07
commit 33cd97fb23

View file

@ -68,6 +68,7 @@ func (p *Publisher) Publish(v interface{}) {
func (p *Publisher) Close() { func (p *Publisher) Close() {
p.m.Lock() p.m.Lock()
for sub := range p.subscribers { for sub := range p.subscribers {
delete(p.subscribers, sub)
close(sub) close(sub)
} }
p.m.Unlock() p.m.Unlock()