Fix lookupTopic
This commit is contained in:
@@ -114,7 +114,7 @@ public:
|
|||||||
for (auto *webSocketContext : webSocketContexts) {
|
for (auto *webSocketContext : webSocketContexts) {
|
||||||
auto *webSocketContextData = webSocketContext->getExt();
|
auto *webSocketContextData = webSocketContext->getExt();
|
||||||
|
|
||||||
Topic *t = webSocketContextData->lookupTopic(topic);
|
Topic *t = webSocketContextData->topicTree.lookupTopic(topic);
|
||||||
if (t) {
|
if (t) {
|
||||||
subscribers += t->subs.size();
|
subscribers += t->subs.size();
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -139,22 +139,6 @@ struct Intersection {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct TopicTree {
|
struct TopicTree {
|
||||||
private:
|
|
||||||
std::function<int(Subscriber *, Intersection &)> cb;
|
|
||||||
|
|
||||||
Topic *root = new Topic;
|
|
||||||
|
|
||||||
/* Global messageId for deduplication of overlapping topics and ordering between topics */
|
|
||||||
unsigned int messageId = 0;
|
|
||||||
|
|
||||||
/* Sender holes */
|
|
||||||
std::map<Subscriber *, std::vector<unsigned int>> senderHoles;
|
|
||||||
|
|
||||||
/* The triggered topics */
|
|
||||||
Topic *triggeredTopics[64];
|
|
||||||
int numTriggeredTopics = 0;
|
|
||||||
Subscriber *min = (Subscriber *) UINTPTR_MAX;
|
|
||||||
|
|
||||||
/* Returns Topic, or nullptr. Topic can be root if empty string given. */
|
/* Returns Topic, or nullptr. Topic can be root if empty string given. */
|
||||||
Topic *lookupTopic(std::string_view topic) {
|
Topic *lookupTopic(std::string_view topic) {
|
||||||
/* Lookup exact Topic ptr from string */
|
/* Lookup exact Topic ptr from string */
|
||||||
@@ -175,6 +159,22 @@ private:
|
|||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::function<int(Subscriber *, Intersection &)> cb;
|
||||||
|
|
||||||
|
Topic *root = new Topic;
|
||||||
|
|
||||||
|
/* Global messageId for deduplication of overlapping topics and ordering between topics */
|
||||||
|
unsigned int messageId = 0;
|
||||||
|
|
||||||
|
/* Sender holes */
|
||||||
|
std::map<Subscriber *, std::vector<unsigned int>> senderHoles;
|
||||||
|
|
||||||
|
/* The triggered topics */
|
||||||
|
Topic *triggeredTopics[64];
|
||||||
|
int numTriggeredTopics = 0;
|
||||||
|
Subscriber *min = (Subscriber *) UINTPTR_MAX;
|
||||||
|
|
||||||
/* Cull or trim unused Topic nodes from leaf to root */
|
/* Cull or trim unused Topic nodes from leaf to root */
|
||||||
void trimTree(Topic *topic) {
|
void trimTree(Topic *topic) {
|
||||||
while (!topic->subs.size() && !topic->children.size() && !topic->terminatingWildcardChild && !topic->wildcardChild) {
|
while (!topic->subs.size() && !topic->children.size() && !topic->terminatingWildcardChild && !topic->wildcardChild) {
|
||||||
|
|||||||
+7
-2
@@ -230,9 +230,14 @@ public:
|
|||||||
(us_socket_context_t *) us_socket_context(SSL, (us_socket_t *) this)
|
(us_socket_context_t *) us_socket_context(SSL, (us_socket_t *) this)
|
||||||
);
|
);
|
||||||
|
|
||||||
Topic *t = webSocketContextData->lookupTopic(topic);
|
WebSocketData *webSocketData = (WebSocketData *) us_socket_ext(SSL, (us_socket_t *) this);
|
||||||
|
if (!webSocketData->subscriber) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Topic *t = webSocketContextData->topicTree.lookupTopic(topic);
|
||||||
if (t) {
|
if (t) {
|
||||||
return t->subs.find(this) != t->subs.end();
|
return t->subs.find(webSocketData->subscriber) != t->subs.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user