Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix overflow of triggered topics
  • Loading branch information
uNetworkingAB committed Sep 6, 2020
1 parent 3396849 commit 03fca62
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/TopicTree.h
Expand Up @@ -124,10 +124,6 @@ struct TopicTree {

/* Should be getData and commit? */
void publish(Topic *iterator, size_t start, size_t stop, std::string_view topic, std::pair<std::string_view, std::string_view> message) {
/* If we already have 64 triggered topics make sure to drain it here */
if (numTriggeredTopics == 64) {
drain();
}

/* Iterate over all segments in given topic */
for (; stop != std::string::npos; start = stop + 1) {
Expand All @@ -151,6 +147,11 @@ struct TopicTree {

/* Add this topic to triggered */
if (!iterator->terminatingWildcardChild->triggered) {
/* If we already have 64 triggered topics make sure to drain it here */
if (numTriggeredTopics == 64) {
drain();
}

triggeredTopics[numTriggeredTopics++] = iterator->terminatingWildcardChild;
iterator->terminatingWildcardChild->triggered = true;
}
Expand All @@ -175,6 +176,11 @@ struct TopicTree {

/* Add this topic to triggered */
if (!iterator->triggered) {
/* If we already have 64 triggered topics make sure to drain it here */
if (numTriggeredTopics == 64) {
drain();
}

triggeredTopics[numTriggeredTopics++] = iterator;
iterator->triggered = true;
}
Expand Down

0 comments on commit 03fca62

Please sign in to comment.