Move counter incrementing before announce
This commit is contained in:
parent
f4f8f3ec12
commit
9a0d2f5948
|
@ -667,15 +667,15 @@ func (p *PubSub) handleAddSubscription(req *addSubReq) {
|
||||||
func (p *PubSub) handleAddRelay(req *addRelayReq) {
|
func (p *PubSub) handleAddRelay(req *addRelayReq) {
|
||||||
topic := req.topic
|
topic := req.topic
|
||||||
|
|
||||||
|
p.myRelays[topic]++
|
||||||
|
|
||||||
// announce we want this topic if neither relays nor subs exist so far
|
// 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.disc.Advertise(topic)
|
||||||
p.announce(topic, true)
|
p.announce(topic, true)
|
||||||
p.rt.Join(topic)
|
p.rt.Join(topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.myRelays[topic]++
|
|
||||||
|
|
||||||
req.resp <- func() {
|
req.resp <- func() {
|
||||||
select {
|
select {
|
||||||
case p.rmRelay <- topic:
|
case p.rmRelay <- topic:
|
||||||
|
|
Loading…
Reference in New Issue