Skip to content

Commit

Permalink
Disconnect sockets in the debstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Jun 26, 2024
1 parent c594840 commit 7336d6a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/client/xdealer_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ namespace xeus
const std::string& ip,
const std::string& port)
: m_socket(context, zmq::socket_type::dealer)
, m_dealer_end_point("")
{
m_socket.connect(get_end_point(transport, ip, port));
m_dealer_end_point = get_end_point(transport, ip, port);
m_socket.connect(m_dealer_end_point);
}

xdealer_channel::~xdealer_channel()
{
m_socket.disconnect(m_dealer_end_point);
}

void xdealer_channel::send_message(zmq::multipart_t& message)
Expand Down
2 changes: 2 additions & 0 deletions src/client/xdealer_channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace xeus

private:
zmq::socket_t m_socket;

std::string m_dealer_end_point;
};
}

Expand Down
5 changes: 4 additions & 1 deletion src/client/xheartbeat_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ namespace xeus
, m_controller(context, zmq::socket_type::rep)
, m_max_retry(max_retry)
, m_heartbeat_timeout(timeout)
, m_heartbeat_end_point("")
{
m_heartbeat.connect(get_end_point(config.m_transport, config.m_ip, config.m_hb_port));
m_heartbeat_end_point = get_end_point(config.m_transport, config.m_ip, config.m_hb_port);
m_heartbeat.connect(m_heartbeat_end_point);
init_socket(m_controller, get_controller_end_point("heartbeat"));
}

xheartbeat_client::~xheartbeat_client()
{
m_heartbeat.disconnect(m_heartbeat_end_point);
}

void xheartbeat_client::send_heartbeat_message()
Expand Down
2 changes: 2 additions & 0 deletions src/client/xheartbeat_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace xeus
kernel_status_listener m_kernel_status_listener;
const std::size_t m_max_retry;
const long m_heartbeat_timeout;

std::string m_heartbeat_end_point;
};
}

Expand Down
5 changes: 4 additions & 1 deletion src/client/xiopub_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ namespace xeus
const xeus::xconfiguration& config)
: m_iopub(context, zmq::socket_type::sub)
, m_controller(context, zmq::socket_type::rep)
, m_iopub_end_point("")
{
m_iopub.connect(get_end_point(config.m_transport, config.m_ip, config.m_iopub_port));
m_iopub_end_point = get_end_point(config.m_transport, config.m_ip, config.m_iopub_port);
m_iopub.connect(m_iopub_end_point);
init_socket(m_controller, get_controller_end_point("iopub"));
}

xiopub_client::~xiopub_client()
{
m_iopub.disconnect(m_iopub_end_point);
}

std::size_t xiopub_client::iopub_queue_size() const
Expand Down
2 changes: 2 additions & 0 deletions src/client/xiopub_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ namespace xeus
zmq::socket_t m_iopub;
zmq::socket_t m_controller;

std::string m_iopub_end_point;

std::queue<xpub_message> m_message_queue;
mutable std::mutex m_queue_mutex;

Expand Down

0 comments on commit 7336d6a

Please sign in to comment.