Skip to content

Commit

Permalink
Added broker side debug log.
Browse files Browse the repository at this point in the history
  • Loading branch information
redboltz committed Nov 19, 2024
1 parent 6949d9c commit 53a380a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tool/include/broker/offline_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ASYNC_MQTT_BROKER_OFFLINE_MESSAGE_HPP

#include <optional>
#include <iostream>

#include <boost/asio/steady_timer.hpp>
#include <boost/multi_index_container.hpp>
Expand Down Expand Up @@ -150,6 +151,7 @@ class offline_messages {
// See https://github.com/boostorg/multi_index/issues/50
auto& m = const_cast<offline_message&>(*it);
if (m.send(epsp, ver)) {
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
idx.pop_front();
}
else {
Expand Down
7 changes: 7 additions & 0 deletions tool/include/broker/session_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <chrono>
#include <set>
#include <iostream>

#include <boost/asio/io_context.hpp>
#include <boost/multi_index_container.hpp>
Expand Down Expand Up @@ -172,6 +173,7 @@ struct session_state : std::enable_shared_from_this<session_state<Sp>> {
}
);

std::cout << __FILE__ << ":" << __LINE__ << std::endl;
insert_inflight_message(
force_move(store),
force_move(tim_message_expiry)
Expand Down Expand Up @@ -311,6 +313,7 @@ struct session_state : std::enable_shared_from_this<session_state<Sp>> {
}

// offline_messages_ is not empty or packet_id_exhausted
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
offline_messages_.push_back(
timer_ioc,
force_move(pub_topic),
Expand Down Expand Up @@ -339,6 +342,7 @@ struct session_state : std::enable_shared_from_this<session_state<Sp>> {
}
else {
std::lock_guard<mutex> g(mtx_offline_messages_);
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
offline_messages_.push_back(
timer_ioc,
force_move(pub_topic),
Expand All @@ -362,10 +366,12 @@ struct session_state : std::enable_shared_from_this<session_state<Sp>> {
will_value_ = std::nullopt;
{
std::lock_guard<mutex> g(mtx_inflight_messages_);
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
inflight_messages_.clear();
}
{
std::lock_guard<mutex> g(mtx_offline_messages_);
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
offline_messages_.clear();
}
unsubscribe_all();
Expand Down Expand Up @@ -558,6 +564,7 @@ struct session_state : std::enable_shared_from_this<session_state<Sp>> {
}

void send_all_offline_messages() {
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
if (auto epsp = lock()) {
std::lock_guard<mutex> g(mtx_offline_messages_);
offline_messages_.send_until_fail(epsp, get_protocol_version());
Expand Down

0 comments on commit 53a380a

Please sign in to comment.