mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-27 19:10:22 +01:00
Problem: process_plug, get_new_reconnect_ivl and add_reconnect_timer duplicated across subclasses of stream_connector_base_t
Solution: pull up to stream_connector_base_t
This commit is contained in:
@@ -64,14 +64,6 @@ zmq::tipc_connecter_t::tipc_connecter_t (class io_thread_t *io_thread_,
|
||||
zmq_assert (_addr->protocol == "tipc");
|
||||
}
|
||||
|
||||
void zmq::tipc_connecter_t::process_plug ()
|
||||
{
|
||||
if (_delayed_start)
|
||||
add_reconnect_timer ();
|
||||
else
|
||||
start_connecting ();
|
||||
}
|
||||
|
||||
void zmq::tipc_connecter_t::process_term (int linger_)
|
||||
{
|
||||
if (_reconnect_timer_started) {
|
||||
@@ -157,35 +149,6 @@ void zmq::tipc_connecter_t::start_connecting ()
|
||||
}
|
||||
}
|
||||
|
||||
void zmq::tipc_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);
|
||||
_reconnect_timer_started = true;
|
||||
}
|
||||
}
|
||||
|
||||
int zmq::tipc_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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
return this_interval;
|
||||
}
|
||||
|
||||
int zmq::tipc_connecter_t::open ()
|
||||
{
|
||||
zmq_assert (_s == retired_fd);
|
||||
|
||||
Reference in New Issue
Block a user