Problem: destructors of tcp_connecter_t, ipc_connecter_t, tipc_connecter_t contain duplicated code

Solution: pull up to stream_connecter_base_t
This commit is contained in:
Simon Giesecke
2019-01-31 08:55:39 -05:00
parent d6f8d246e2
commit 74667ebcba
7 changed files with 10 additions and 19 deletions

View File

@@ -62,13 +62,6 @@ zmq::ipc_connecter_t::ipc_connecter_t (class io_thread_t *io_thread_,
zmq_assert (_addr->protocol == protocol_name::ipc); zmq_assert (_addr->protocol == protocol_name::ipc);
} }
zmq::ipc_connecter_t::~ipc_connecter_t ()
{
zmq_assert (!_reconnect_timer_started);
zmq_assert (_handle == static_cast<handle_t> (NULL));
zmq_assert (_s == retired_fd);
}
void zmq::ipc_connecter_t::process_plug () void zmq::ipc_connecter_t::process_plug ()
{ {
if (_delayed_start) if (_delayed_start)

View File

@@ -48,7 +48,6 @@ class ipc_connecter_t : public stream_connecter_base_t
const options_t &options_, const options_t &options_,
address_t *addr_, address_t *addr_,
bool delayed_start_); bool delayed_start_);
~ipc_connecter_t ();
private: private:
// ID of the timer used to delay the reconnection. // ID of the timer used to delay the reconnection.

View File

@@ -55,3 +55,10 @@ zmq::stream_connecter_base_t::stream_connecter_base_t (
// or does not matter, change such that endpoint in initialized using an // or does not matter, change such that endpoint in initialized using an
// initializer, and make endpoint const // initializer, and make endpoint const
} }
zmq::stream_connecter_base_t::~stream_connecter_base_t ()
{
zmq_assert (!_reconnect_timer_started);
zmq_assert (!_handle);
zmq_assert (_s == retired_fd);
}

View File

@@ -51,6 +51,9 @@ class stream_connecter_base_t : public own_t, public io_object_t
address_t *addr_, address_t *addr_,
bool delayed_start_); bool delayed_start_);
~stream_connecter_base_t ();
protected: protected:
// 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.

View File

@@ -79,9 +79,6 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
zmq::tcp_connecter_t::~tcp_connecter_t () zmq::tcp_connecter_t::~tcp_connecter_t ()
{ {
zmq_assert (!_connect_timer_started); zmq_assert (!_connect_timer_started);
zmq_assert (!_reconnect_timer_started);
zmq_assert (!_handle);
zmq_assert (_s == retired_fd);
} }
void zmq::tcp_connecter_t::process_plug () void zmq::tcp_connecter_t::process_plug ()

View File

@@ -64,13 +64,6 @@ zmq::tipc_connecter_t::tipc_connecter_t (class io_thread_t *io_thread_,
zmq_assert (_addr->protocol == "tipc"); zmq_assert (_addr->protocol == "tipc");
} }
zmq::tipc_connecter_t::~tipc_connecter_t ()
{
zmq_assert (!_reconnect_timer_started);
zmq_assert (_handle == static_cast<handle_t> (NULL));
zmq_assert (_s == retired_fd);
}
void zmq::tipc_connecter_t::process_plug () void zmq::tipc_connecter_t::process_plug ()
{ {
if (_delayed_start) if (_delayed_start)

View File

@@ -49,7 +49,6 @@ class tipc_connecter_t : public stream_connecter_base_t
const options_t &options_, const options_t &options_,
address_t *addr_, address_t *addr_,
bool delayed_start_); bool delayed_start_);
~tipc_connecter_t ();
private: private:
// ID of the timer used to delay the reconnection. // ID of the timer used to delay the reconnection.