From a40a3b7a34e58cfae3c23adf3ca1ea71256f315e Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Thu, 31 Jan 2019 10:11:31 -0500 Subject: [PATCH] Problem: several data members in stream_connecter_base_t are visible more than necessary Solution: make them private and adapt initialization order --- src/stream_connecter_base.cpp | 4 ++-- src/stream_connecter_base.hpp | 42 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/stream_connecter_base.cpp b/src/stream_connecter_base.cpp index ae070ed5..acb7ace2 100644 --- a/src/stream_connecter_base.cpp +++ b/src/stream_connecter_base.cpp @@ -44,11 +44,11 @@ zmq::stream_connecter_base_t::stream_connecter_base_t ( _addr (addr_), _s (retired_fd), _handle (static_cast (NULL)), + _socket (session_->get_socket ()), _delayed_start (delayed_start_), _reconnect_timer_started (false), _session (session_), - _current_reconnect_ivl (options.reconnect_ivl), - _socket (_session->get_socket ()) + _current_reconnect_ivl (options.reconnect_ivl) { zmq_assert (_addr); _addr->to_string (_endpoint); diff --git a/src/stream_connecter_base.hpp b/src/stream_connecter_base.hpp index 7c4b4075..d8a789be 100644 --- a/src/stream_connecter_base.hpp +++ b/src/stream_connecter_base.hpp @@ -53,21 +53,6 @@ class stream_connecter_base_t : public own_t, public io_object_t ~stream_connecter_base_t (); - private: - // ID of the timer used to delay the reconnection. - enum - { - reconnect_timer_id = 1 - }; - - // Internal function to return a reconnect backoff delay. - // Will modify the current_reconnect_ivl used for next call - // Returns the currently used interval - int get_new_reconnect_ivl (); - - virtual void start_connecting () = 0; - - // TODO check if some members can be made private protected: // Handlers for incoming commands. void process_plug (); @@ -100,6 +85,26 @@ class stream_connecter_base_t : public own_t, public io_object_t // registered with the poller, or NULL. handle_t _handle; + // String representation of endpoint to connect to + std::string _endpoint; + + // Socket + zmq::socket_base_t *const _socket; + + private: + // ID of the timer used to delay the reconnection. + enum + { + reconnect_timer_id = 1 + }; + + // Internal function to return a reconnect backoff delay. + // Will modify the current_reconnect_ivl used for next call + // Returns the currently used interval + int get_new_reconnect_ivl (); + + virtual void start_connecting () = 0; + // If true, connecter is waiting a while before trying to connect. const bool _delayed_start; @@ -112,13 +117,6 @@ class stream_connecter_base_t : public own_t, public io_object_t // Current reconnect ivl, updated for backoff strategy int _current_reconnect_ivl; - // String representation of endpoint to connect to - std::string _endpoint; - - // Socket - zmq::socket_base_t *const _socket; - - private: stream_connecter_base_t (const stream_connecter_base_t &); const stream_connecter_base_t &operator= (const stream_connecter_base_t &); };