mirror of
https://github.com/zeromq/libzmq.git
synced 2025-02-23 15:14:40 +01:00
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:
parent
1a230e89ca
commit
531df586d0
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 ();
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user