mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-22 10:25:52 +01:00
Problem: tipc_connector_t::_handle_valid is redundant
Solution: replace by checks against valid value of _handle
This commit is contained in:
parent
a13eb1a9d8
commit
361d7168ad
@ -62,7 +62,7 @@ zmq::tipc_connecter_t::tipc_connecter_t (class io_thread_t *io_thread_,
|
|||||||
io_object_t (io_thread_),
|
io_object_t (io_thread_),
|
||||||
_addr (addr_),
|
_addr (addr_),
|
||||||
_s (retired_fd),
|
_s (retired_fd),
|
||||||
_handle_valid (false),
|
_handle (static_cast<handle_t> (NULL)),
|
||||||
_delayed_start (delayed_start_),
|
_delayed_start (delayed_start_),
|
||||||
_reconnect_timer_started (false),
|
_reconnect_timer_started (false),
|
||||||
_session (session_),
|
_session (session_),
|
||||||
@ -77,7 +77,7 @@ zmq::tipc_connecter_t::tipc_connecter_t (class io_thread_t *io_thread_,
|
|||||||
zmq::tipc_connecter_t::~tipc_connecter_t ()
|
zmq::tipc_connecter_t::~tipc_connecter_t ()
|
||||||
{
|
{
|
||||||
zmq_assert (!_reconnect_timer_started);
|
zmq_assert (!_reconnect_timer_started);
|
||||||
zmq_assert (!_handle_valid);
|
zmq_assert (_handle == static_cast<handle_t> (NULL));
|
||||||
zmq_assert (_s == retired_fd);
|
zmq_assert (_s == retired_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +96,9 @@ void zmq::tipc_connecter_t::process_term (int linger_)
|
|||||||
_reconnect_timer_started = false;
|
_reconnect_timer_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_handle_valid) {
|
if (_handle) {
|
||||||
rm_fd (_handle);
|
rm_fd (_handle);
|
||||||
_handle_valid = false;
|
_handle = static_cast<handle_t> (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_s != retired_fd)
|
if (_s != retired_fd)
|
||||||
@ -119,7 +119,7 @@ void zmq::tipc_connecter_t::out_event ()
|
|||||||
{
|
{
|
||||||
fd_t fd = connect ();
|
fd_t fd = connect ();
|
||||||
rm_fd (_handle);
|
rm_fd (_handle);
|
||||||
_handle_valid = false;
|
_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) {
|
||||||
@ -156,14 +156,12 @@ void zmq::tipc_connecter_t::start_connecting ()
|
|||||||
// Connect may succeed in synchronous manner.
|
// Connect may succeed in synchronous manner.
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
_handle = add_fd (_s);
|
_handle = add_fd (_s);
|
||||||
_handle_valid = true;
|
|
||||||
out_event ();
|
out_event ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection establishment may be delayed. Poll for its completion.
|
// Connection establishment may be delayed. Poll for its completion.
|
||||||
else if (rc == -1 && errno == EINPROGRESS) {
|
else if (rc == -1 && errno == EINPROGRESS) {
|
||||||
_handle = add_fd (_s);
|
_handle = add_fd (_s);
|
||||||
_handle_valid = true;
|
|
||||||
set_pollout (_handle);
|
set_pollout (_handle);
|
||||||
_socket->event_connect_delayed (_endpoint, zmq_errno ());
|
_socket->event_connect_delayed (_endpoint, zmq_errno ());
|
||||||
}
|
}
|
||||||
|
@ -95,10 +95,6 @@ class tipc_connecter_t : public own_t, public io_object_t
|
|||||||
// Handle corresponding to the listening socket.
|
// 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;
|
|
||||||
|
|
||||||
// If true, connecter is waiting a while before trying to connect.
|
// If true, connecter is waiting a while before trying to connect.
|
||||||
const bool _delayed_start;
|
const bool _delayed_start;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user