Commit 531df586 authored by Simon Giesecke's avatar Simon Giesecke

Problem: rm_fd code duplicated across stream_connecter_t subclasses

Solution: pull up tcp_connecter_t::rm_handle and use in all subclasses
parent 1a230e89
...@@ -70,8 +70,7 @@ void zmq::ipc_connecter_t::process_term (int linger_) ...@@ -70,8 +70,7 @@ void zmq::ipc_connecter_t::process_term (int linger_)
} }
if (_handle) { if (_handle) {
rm_fd (_handle); rm_handle ();
_handle = static_cast<handle_t> (NULL);
} }
if (_s != retired_fd) if (_s != retired_fd)
...@@ -91,8 +90,7 @@ void zmq::ipc_connecter_t::in_event () ...@@ -91,8 +90,7 @@ void zmq::ipc_connecter_t::in_event ()
void zmq::ipc_connecter_t::out_event () void zmq::ipc_connecter_t::out_event ()
{ {
fd_t fd = connect (); fd_t fd = connect ();
rm_fd (_handle); rm_handle ();
_handle = static_cast<handle_t> (NULL);
// Handle the error condition by attempt to reconnect. // Handle the error condition by attempt to reconnect.
if (fd == retired_fd) { if (fd == retired_fd) {
......
...@@ -97,3 +97,9 @@ int zmq::stream_connecter_base_t::get_new_reconnect_ivl () ...@@ -97,3 +97,9 @@ int zmq::stream_connecter_base_t::get_new_reconnect_ivl ()
std::min (_current_reconnect_ivl * 2, options.reconnect_ivl_max); std::min (_current_reconnect_ivl * 2, options.reconnect_ivl_max);
return interval; return interval;
} }
void zmq::stream_connecter_base_t::rm_handle ()
{
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
}
...@@ -75,6 +75,9 @@ class stream_connecter_base_t : public own_t, public io_object_t ...@@ -75,6 +75,9 @@ class stream_connecter_base_t : public own_t, public io_object_t
// Internal function to add a reconnect timer // Internal function to add a reconnect timer
void add_reconnect_timer (); void add_reconnect_timer ();
// Removes the handle from the poller.
void rm_handle ();
// Address to connect to. Owned by session_base_t. // Address to connect to. Owned by session_base_t.
// It is non-const since some parts may change during opening. // It is non-const since some parts may change during opening.
address_t *const _addr; address_t *const _addr;
......
...@@ -142,12 +142,6 @@ void zmq::tcp_connecter_t::out_event () ...@@ -142,12 +142,6 @@ void zmq::tcp_connecter_t::out_event ()
_socket->event_connected (_endpoint, fd); _socket->event_connected (_endpoint, fd);
} }
void zmq::tcp_connecter_t::rm_handle ()
{
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
}
void zmq::tcp_connecter_t::timer_event (int id_) void zmq::tcp_connecter_t::timer_event (int id_)
{ {
zmq_assert (id_ == reconnect_timer_id || id_ == connect_timer_id); zmq_assert (id_ == reconnect_timer_id || id_ == connect_timer_id);
......
...@@ -63,9 +63,6 @@ class tcp_connecter_t : public stream_connecter_base_t ...@@ -63,9 +63,6 @@ class tcp_connecter_t : public stream_connecter_base_t
void out_event (); void out_event ();
void timer_event (int id_); void timer_event (int id_);
// Removes the handle from the poller.
void rm_handle ();
// Internal function to start the actual connection establishment. // Internal function to start the actual connection establishment.
void start_connecting (); void start_connecting ();
......
...@@ -72,8 +72,7 @@ void zmq::tipc_connecter_t::process_term (int linger_) ...@@ -72,8 +72,7 @@ void zmq::tipc_connecter_t::process_term (int linger_)
} }
if (_handle) { if (_handle) {
rm_fd (_handle); rm_handle ();
_handle = static_cast<handle_t> (NULL);
} }
if (_s != retired_fd) if (_s != retired_fd)
...@@ -93,8 +92,7 @@ void zmq::tipc_connecter_t::in_event () ...@@ -93,8 +92,7 @@ void zmq::tipc_connecter_t::in_event ()
void zmq::tipc_connecter_t::out_event () void zmq::tipc_connecter_t::out_event ()
{ {
fd_t fd = connect (); fd_t fd = connect ();
rm_fd (_handle); rm_handle ();
_handle = static_cast<handle_t> (NULL);
// Handle the error condition by attempt to reconnect. // Handle the error condition by attempt to reconnect.
if (fd == retired_fd) { if (fd == retired_fd) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment