Move counter incrementing before announce

This commit is contained in:
Lukasz Zimnoch 2020-05-01 10:38:06 +02:00 committed by vyzo
parent f4f8f3ec12
commit 9a0d2f5948
1 changed files with 3 additions and 3 deletions

View File

@ -667,15 +667,15 @@ func (p *PubSub) handleAddSubscription(req *addSubReq) {
func (p *PubSub) handleAddRelay(req *addRelayReq) {
topic := req.topic
p.myRelays[topic]++
// announce we want this topic if neither relays nor subs exist so far
if p.myRelays[topic] == 0 && len(p.mySubs[topic]) == 0 {
if p.myRelays[topic] == 1 && len(p.mySubs[topic]) == 0 {
p.disc.Advertise(topic)
p.announce(topic, true)
p.rt.Join(topic)
}
p.myRelays[topic]++
req.resp <- func() {
select {
case p.rmRelay <- topic: