Skip to content

Commit

Permalink
Merge pull request #70 from JohanMabille/client_fix
Browse files Browse the repository at this point in the history
Fixed many uninitialized pointers
  • Loading branch information
JohanMabille authored Jun 28, 2024
2 parents 0a5de78 + 1d73a3b commit 3f50879
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/client/xclient_zmq_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace xeus
: p_auth(make_xauthentication(config.m_signature_scheme, config.m_key))
, m_shell_client(context, config.m_transport, config.m_ip, config.m_shell_port)
, m_control_client(context, config.m_transport, config.m_ip, config.m_control_port)
, m_iopub_client(context, config)
, m_iopub_client(context, config, this)
, m_heartbeat_client(context, config, max_retry, heartbeat_timeout)
, p_messenger(context)
, m_error_handler(eh)
Expand Down Expand Up @@ -174,7 +174,9 @@ namespace xeus
if (pending_message.has_value())
{
notify_iopub_listener(std::move(*pending_message));
} else {
}
else
{
poll(-1);
}
}
Expand All @@ -187,12 +189,12 @@ namespace xeus

void xclient_zmq_impl::start_iopub_thread()
{
m_iopub_thread = std::move(xthread(&xiopub_client::run, p_iopub_client.get()));
m_iopub_thread = std::move(xthread(&xiopub_client::run, &m_iopub_client));
}

void xclient_zmq_impl::start_heartbeat_thread()
{
m_heartbeat_thread = std::move(xthread(&xheartbeat_client::run, p_heartbeat_client.get()));
m_heartbeat_thread = std::move(xthread(&xheartbeat_client::run, &m_heartbeat_client));
}

xmessage xclient_zmq_impl::deserialize(zmq::multipart_t& wire_msg) const
Expand Down
3 changes: 0 additions & 3 deletions src/client/xclient_zmq_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ namespace xeus
listener m_control_listener;
iopub_listener m_iopub_listener;

iopub_client_ptr p_iopub_client;
heartbeat_client_ptr p_heartbeat_client;

xthread m_iopub_thread;
xthread m_heartbeat_thread;
};
Expand Down
8 changes: 6 additions & 2 deletions src/client/xheartbeat_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ namespace xeus
if (retry_count < m_max_retry)
{
++retry_count;
} else {
}
else
{
notify_kernel_dead(true);
stop = true;
}
} else {
}
else
{
retry_count = 0;
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Expand Down
9 changes: 7 additions & 2 deletions src/client/xiopub_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ namespace xeus
{

xiopub_client::xiopub_client(zmq::context_t& context,
const xeus::xconfiguration& config)
const xeus::xconfiguration& config,
xclient_zmq_impl* client)
: m_iopub(context, zmq::socket_type::sub)
, m_controller(context, zmq::socket_type::rep)
, m_iopub_end_point("")
, p_client_impl(client)
{
m_iopub_end_point = get_end_point(config.m_transport, config.m_ip, config.m_iopub_port);
m_iopub.connect(m_iopub_end_point);
m_iopub.set(zmq::sockopt::subscribe, "");
init_socket(m_controller, get_controller_end_point("iopub"));
}

Expand All @@ -47,7 +50,9 @@ namespace xeus
xpub_message msg = std::move(m_message_queue.back());
m_message_queue.pop();
return msg;
} else {
}
else
{
return std::nullopt;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/client/xiopub_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ namespace xeus
public:

xiopub_client(zmq::context_t& context,
const xeus::xconfiguration& config);
const xeus::xconfiguration& config,
xclient_zmq_impl* client);

~xiopub_client();

Expand All @@ -49,4 +50,4 @@ namespace xeus
};
}

#endif
#endif

0 comments on commit 3f50879

Please sign in to comment.