Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

The QosFailure will never return #56

Open
it-man-cn opened this issue Jul 6, 2017 · 0 comments
Open

The QosFailure will never return #56

it-man-cn opened this issue Jul 6, 2017 · 0 comments

Comments

@it-man-cn
Copy link

The QosFailure will never return to client

The Subscribe function in memtopics.go message.QosFailure always whith some err.
https://github.com/influxdata/surgemq/blob/master/topics/memtopics.go#L61

func (this *memTopics) Subscribe(topic []byte, qos byte, sub interface{}) (byte, error) {
	if !message.ValidQos(qos) {
		return message.QosFailure, fmt.Errorf("Invalid QoS %d", qos)
	}

	if sub == nil {
		return message.QosFailure, fmt.Errorf("Subscriber cannot be nil")
	}

	this.smu.Lock()
	defer this.smu.Unlock()

	if qos > MaxQosAllowed {
		qos = MaxQosAllowed
	}

	if err := this.sroot.sinsert(topic, qos, sub); err != nil {
		return message.QosFailure, err
	}

	return qos, nil
}

But the processSubscribe function in process.go ,when Subscribe return err QosFailure will not append into retcodes but function return

https://github.com/influxdata/surgemq/blob/master/service/process.go#L315

for i, t := range topics {
	rqos, err := this.topicsMgr.Subscribe(t, qos[i], &this.onpub)
	if err != nil {
		return err
	}
	this.sess.AddTopic(string(t), qos[i])

	retcodes = append(retcodes, rqos)

	// yeah I am not checking errors here. If there's an error we don't want the
	// subscription to stop, just let it go.
	this.topicsMgr.Retained(t, &this.rmsgs)
	glog.Debugf("(%s) topic = %s, retained count = %d", this.cid(), string(t), len(this.rmsgs))
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant