-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Erase MessageHandler for topics without any registered handlers #229
Erase MessageHandler for topics without any registered handlers #229
Conversation
This drastically reduces the amount of lingering threads just hanging around and doing absolutely nothing Signed-off-by: Kai-Uwe Hermann <[email protected]>
Signed-off-by: Kai-Uwe Hermann <[email protected]>
lib/mqtt_abstraction_impl.cpp
Outdated
if (!found) { | ||
EVLOG_AND_THROW( | ||
EverestInternalError(fmt::format("Internal error: topic '{}' should have a matching handler!", topic))); | ||
EVLOG_warning << fmt::format("Internal error: topic '{}' should have a matching handler!", topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really an error, as is written in the comment, this is an valid but unlikely event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to a verbose log and slightly reworded the comment
lib/mqtt_abstraction_impl.cpp
Outdated
|
||
// only subscribe for this topic if we aren't already and the mqtt client is connected | ||
// if we are not connected the on_mqtt_connect() callback will subscribe to the topic | ||
if (this->mqtt_is_connected && this->message_handlers[topic].count_handlers() == 1) { | ||
if (this->mqtt_is_connected && this->message_handlers.at(topic).count_handlers() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing this the first time, why should count_handlers() == 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's because if count_handler == 1 after registering a new handler it was the first handler being registered which should then trigger a subscribe
Signed-off-by: Kai-Uwe Hermann <[email protected]>
Signed-off-by: Kai-Uwe Hermann <[email protected]>
Signed-off-by: Kai-Uwe Hermann <[email protected]>
This drastically reduces the amount of lingering threads just hanging around and doing absolutely nothing