Problem: ipc_connector_t data members not conforming to naming conventions

Solution: add underscore prefix to data members
This commit is contained in:
Simon Giesecke 2019-01-31 08:17:26 -05:00
parent 4d362887bb
commit 58063a75a2
2 changed files with 63 additions and 63 deletions

View File

@ -58,30 +58,30 @@ zmq::ipc_connecter_t::ipc_connecter_t (class io_thread_t *io_thread_,
bool delayed_start_) :
own_t (io_thread_, options_),
io_object_t (io_thread_),
addr (addr_),
s (retired_fd),
handle_valid (false),
delayed_start (delayed_start_),
timer_started (false),
session (session_),
current_reconnect_ivl (options.reconnect_ivl)
_addr (addr_),
_s (retired_fd),
_handle_valid (false),
_delayed_start (delayed_start_),
_timer_started (false),
_session (session_),
_current_reconnect_ivl (options.reconnect_ivl)
{
zmq_assert (addr);
zmq_assert (addr->protocol == protocol_name::ipc);
addr->to_string (endpoint);
socket = session->get_socket ();
zmq_assert (_addr);
zmq_assert (_addr->protocol == protocol_name::ipc);
_addr->to_string (_endpoint);
_socket = _session->get_socket ();
}
zmq::ipc_connecter_t::~ipc_connecter_t ()
{
zmq_assert (!timer_started);
zmq_assert (!handle_valid);
zmq_assert (s == retired_fd);
zmq_assert (!_timer_started);
zmq_assert (!_handle_valid);
zmq_assert (_s == retired_fd);
}
void zmq::ipc_connecter_t::process_plug ()
{
if (delayed_start)
if (_delayed_start)
add_reconnect_timer ();
else
start_connecting ();
@ -89,17 +89,17 @@ void zmq::ipc_connecter_t::process_plug ()
void zmq::ipc_connecter_t::process_term (int linger_)
{
if (timer_started) {
if (_timer_started) {
cancel_timer (reconnect_timer_id);
timer_started = false;
_timer_started = false;
}
if (handle_valid) {
rm_fd (handle);
handle_valid = false;
if (_handle_valid) {
rm_fd (_handle);
_handle_valid = false;
}
if (s != retired_fd)
if (_s != retired_fd)
close ();
own_t::process_term (linger_);
@ -116,8 +116,8 @@ void zmq::ipc_connecter_t::in_event ()
void zmq::ipc_connecter_t::out_event ()
{
fd_t fd = connect ();
rm_fd (handle);
handle_valid = false;
rm_fd (_handle);
_handle_valid = false;
// Handle the error condition by attempt to reconnect.
if (fd == retired_fd) {
@ -127,22 +127,22 @@ void zmq::ipc_connecter_t::out_event ()
}
// Create the engine object for this connection.
stream_engine_t *engine =
new (std::nothrow) stream_engine_t (fd, options, endpoint);
new (std::nothrow) stream_engine_t (fd, options, _endpoint);
alloc_assert (engine);
// Attach the engine to the corresponding session object.
send_attach (session, engine);
send_attach (_session, engine);
// Shut the connecter down.
terminate ();
socket->event_connected (endpoint, fd);
_socket->event_connected (_endpoint, fd);
}
void zmq::ipc_connecter_t::timer_event (int id_)
{
zmq_assert (id_ == reconnect_timer_id);
timer_started = false;
_timer_started = false;
start_connecting ();
}
@ -153,22 +153,22 @@ void zmq::ipc_connecter_t::start_connecting ()
// Connect may succeed in synchronous manner.
if (rc == 0) {
handle = add_fd (s);
handle_valid = true;
_handle = add_fd (_s);
_handle_valid = true;
out_event ();
}
// Connection establishment may be delayed. Poll for its completion.
else if (rc == -1 && errno == EINPROGRESS) {
handle = add_fd (s);
handle_valid = true;
set_pollout (handle);
socket->event_connect_delayed (endpoint, zmq_errno ());
_handle = add_fd (_s);
_handle_valid = true;
set_pollout (_handle);
_socket->event_connect_delayed (_endpoint, zmq_errno ());
}
// Handle any other error condition by eventual reconnect.
else {
if (s != retired_fd)
if (_s != retired_fd)
close ();
add_reconnect_timer ();
}
@ -179,8 +179,8 @@ void zmq::ipc_connecter_t::add_reconnect_timer ()
if (options.reconnect_ivl != -1) {
int rc_ivl = get_new_reconnect_ivl ();
add_timer (rc_ivl, reconnect_timer_id);
socket->event_connect_retried (endpoint, rc_ivl);
timer_started = true;
_socket->event_connect_retried (_endpoint, rc_ivl);
_timer_started = true;
}
}
@ -188,16 +188,16 @@ int zmq::ipc_connecter_t::get_new_reconnect_ivl ()
{
// The new interval is the current interval + random value.
int this_interval =
current_reconnect_ivl + (generate_random () % options.reconnect_ivl);
_current_reconnect_ivl + (generate_random () % options.reconnect_ivl);
// Only change the current reconnect interval if the maximum reconnect
// interval was set and if it's larger than the reconnect interval.
if (options.reconnect_ivl_max > 0
&& options.reconnect_ivl_max > options.reconnect_ivl) {
// Calculate the next interval
current_reconnect_ivl = current_reconnect_ivl * 2;
if (current_reconnect_ivl >= options.reconnect_ivl_max) {
current_reconnect_ivl = options.reconnect_ivl_max;
_current_reconnect_ivl = _current_reconnect_ivl * 2;
if (_current_reconnect_ivl >= options.reconnect_ivl_max) {
_current_reconnect_ivl = options.reconnect_ivl_max;
}
}
return this_interval;
@ -205,19 +205,19 @@ int zmq::ipc_connecter_t::get_new_reconnect_ivl ()
int zmq::ipc_connecter_t::open ()
{
zmq_assert (s == retired_fd);
zmq_assert (_s == retired_fd);
// Create the socket.
s = open_socket (AF_UNIX, SOCK_STREAM, 0);
if (s == -1)
_s = open_socket (AF_UNIX, SOCK_STREAM, 0);
if (_s == -1)
return -1;
// Set the non-blocking flag.
unblock_socket (s);
unblock_socket (_s);
// Connect to the remote peer.
int rc = ::connect (s, addr->resolved.ipc_addr->addr (),
addr->resolved.ipc_addr->addrlen ());
int rc = ::connect (_s, _addr->resolved.ipc_addr->addr (),
_addr->resolved.ipc_addr->addrlen ());
// Connect was successful immediately.
if (rc == 0)
@ -236,11 +236,11 @@ int zmq::ipc_connecter_t::open ()
int zmq::ipc_connecter_t::close ()
{
zmq_assert (s != retired_fd);
int rc = ::close (s);
zmq_assert (_s != retired_fd);
int rc = ::close (_s);
errno_assert (rc == 0);
socket->event_closed (endpoint, s);
s = retired_fd;
_socket->event_closed (_endpoint, _s);
_s = retired_fd;
return 0;
}
@ -254,7 +254,7 @@ zmq::fd_t zmq::ipc_connecter_t::connect ()
#else
socklen_t len = sizeof (err);
#endif
int rc = getsockopt (s, SOL_SOCKET, SO_ERROR,
int rc = getsockopt (_s, SOL_SOCKET, SO_ERROR,
reinterpret_cast<char *> (&err), &len);
if (rc == -1) {
if (errno == ENOPROTOOPT)
@ -272,8 +272,8 @@ zmq::fd_t zmq::ipc_connecter_t::connect ()
return retired_fd;
}
fd_t result = s;
s = retired_fd;
fd_t result = _s;
_s = retired_fd;
return result;
}

View File

@ -96,35 +96,35 @@ class ipc_connecter_t : public own_t, public io_object_t
fd_t connect ();
// Address to connect to. Owned by session_base_t.
const address_t *addr;
const address_t *_addr;
// Underlying socket.
fd_t s;
fd_t _s;
// Handle corresponding to the listening socket.
handle_t handle;
handle_t _handle;
// If true file descriptor is registered with the poller and 'handle'
// contains valid value.
bool handle_valid;
bool _handle_valid;
// If true, connecter is waiting a while before trying to connect.
const bool delayed_start;
const bool _delayed_start;
// True iff a timer has been started.
bool timer_started;
bool _timer_started;
// Reference to the session we belong to.
zmq::session_base_t *session;
zmq::session_base_t *_session;
// Current reconnect ivl, updated for backoff strategy
int current_reconnect_ivl;
int _current_reconnect_ivl;
// String representation of endpoint to connect to
std::string endpoint;
std::string _endpoint;
// Socket
zmq::socket_base_t *socket;
zmq::socket_base_t *_socket;
ipc_connecter_t (const ipc_connecter_t &);
const ipc_connecter_t &operator= (const ipc_connecter_t &);