Merge pull request #72 from libp2p/fix/issue-69

Don't block the event loop because of slow subscriptions
This commit is contained in:
vyzo 2018-03-07 08:06:55 +02:00 committed by GitHub
commit 7f3ecddf94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,7 +326,11 @@ func (p *PubSub) notifySubs(msg *pb.Message) {
for _, topic := range msg.GetTopicIDs() {
subs := p.myTopics[topic]
for f := range subs {
f.ch <- &Message{msg}
select {
case f.ch <- &Message{msg}:
default:
log.Infof("Can't deliver message to subscription for topic %s; subscriber too slow", topic)
}
}
}
}