Problem: rm_fd code duplicated across stream_connecter_t subclasses

Solution: pull up tcp_connecter_t::rm_handle and use in all subclasses
This commit is contained in:
Simon Giesecke 2019-01-31 09:33:52 -05:00
parent 1a230e89ca
commit 531df586d0
6 changed files with 13 additions and 17 deletions

View File

@ -70,8 +70,7 @@ void zmq::ipc_connecter_t::process_term (int linger_)
}
if (_handle) {
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
rm_handle ();
}
if (_s != retired_fd)
@ -91,8 +90,7 @@ void zmq::ipc_connecter_t::in_event ()
void zmq::ipc_connecter_t::out_event ()
{
fd_t fd = connect ();
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
rm_handle ();
// Handle the error condition by attempt to reconnect.
if (fd == retired_fd) {

View File

@ -97,3 +97,9 @@ int zmq::stream_connecter_base_t::get_new_reconnect_ivl ()
std::min (_current_reconnect_ivl * 2, options.reconnect_ivl_max);
return interval;
}
void zmq::stream_connecter_base_t::rm_handle ()
{
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
}

View File

@ -75,6 +75,9 @@ class stream_connecter_base_t : public own_t, public io_object_t
// Internal function to add a reconnect timer
void add_reconnect_timer ();
// Removes the handle from the poller.
void rm_handle ();
// Address to connect to. Owned by session_base_t.
// It is non-const since some parts may change during opening.
address_t *const _addr;

View File

@ -142,12 +142,6 @@ void zmq::tcp_connecter_t::out_event ()
_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_)
{
zmq_assert (id_ == reconnect_timer_id || id_ == connect_timer_id);

View File

@ -63,9 +63,6 @@ class tcp_connecter_t : public stream_connecter_base_t
void out_event ();
void timer_event (int id_);
// Removes the handle from the poller.
void rm_handle ();
// Internal function to start the actual connection establishment.
void start_connecting ();

View File

@ -72,8 +72,7 @@ void zmq::tipc_connecter_t::process_term (int linger_)
}
if (_handle) {
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
rm_handle ();
}
if (_s != retired_fd)
@ -93,8 +92,7 @@ void zmq::tipc_connecter_t::in_event ()
void zmq::tipc_connecter_t::out_event ()
{
fd_t fd = connect ();
rm_fd (_handle);
_handle = static_cast<handle_t> (NULL);
rm_handle ();
// Handle the error condition by attempt to reconnect.
if (fd == retired_fd) {