mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-07 15:23:08 +00:00
announce retry should check the pubsub context for cancellation
This commit is contained in:
parent
0824316326
commit
2544ae7df9
@ -339,12 +339,18 @@ func (p *PubSub) announce(topic string, sub bool) {
|
|||||||
|
|
||||||
func (p *PubSub) announceRetry(topic string, sub bool) {
|
func (p *PubSub) announceRetry(topic string, sub bool) {
|
||||||
time.Sleep(time.Duration(1+rand.Intn(1000)) * time.Millisecond)
|
time.Sleep(time.Duration(1+rand.Intn(1000)) * time.Millisecond)
|
||||||
p.eval <- func() {
|
|
||||||
|
retry := func() {
|
||||||
_, ok := p.myTopics[topic]
|
_, ok := p.myTopics[topic]
|
||||||
if (ok && sub) || (!ok && !sub) {
|
if (ok && sub) || (!ok && !sub) {
|
||||||
p.announce(topic, sub)
|
p.announce(topic, sub)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case p.eval <- retry:
|
||||||
|
case <-p.ctx.Done():
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// notifySubs sends a given message to all corresponding subscribers.
|
// notifySubs sends a given message to all corresponding subscribers.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user