This commit is contained in:
zhouyuyan
2017-09-07 15:31:38 +08:00
parent ae1af54c6e
commit 4300a32f6b
2 changed files with 45 additions and 69 deletions

View File

@@ -407,7 +407,7 @@ func (b *Broker) PublishMessage(packet *packets.PublishPacket) {
topic := packet.TopicName
r := b.sl.Match(topic)
// log.Info("psubs num: ", len(r.psubs))
if len(r.qsubs) == 0 && len(r.psubs) == 0 {
if len(r.psubs) == 0 {
return
}
@@ -419,21 +419,6 @@ func (b *Broker) PublishMessage(packet *packets.PublishPacket) {
}
}
}
for i, sub := range r.qsubs {
// s.qmu.Lock()
if cnt, exist := b.queues[string(sub.topic)]; exist && i == cnt {
if sub != nil {
err := sub.client.WriterPacket(packet)
if err != nil {
log.Error("process will message for qsub error, ", err)
}
}
b.queues[topic] = (b.queues[topic] + 1) % len(r.qsubs)
break
}
// s.qmu.Unlock()
}
}
func (b *Broker) BroadcastUnSubscribe(subs map[string]*subscription) {