Significantly reworked the monitoring infrastructure with a more granular per socket API and to play well with monitoring endpoints in application threads

This commit is contained in:
Lourens Naudé
2012-09-21 12:53:31 +01:00
parent 7a40df6d3a
commit 759d453368
20 changed files with 768 additions and 432 deletions

View File

@@ -66,6 +66,7 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
zmq_assert (addr);
zmq_assert (addr->protocol == "tcp");
addr->to_string (endpoint);
socket = session-> get_socket();
}
zmq::tcp_connecter_t::~tcp_connecter_t ()
@@ -135,7 +136,7 @@ void zmq::tcp_connecter_t::out_event ()
// Shut the connecter down.
terminate ();
session->monitor_event (ZMQ_EVENT_CONNECTED, endpoint.c_str(), fd);
socket->event_connected (endpoint.c_str(), fd);
}
void zmq::tcp_connecter_t::timer_event (int id_)
@@ -162,7 +163,7 @@ void zmq::tcp_connecter_t::start_connecting ()
handle = add_fd (s);
handle_valid = true;
set_pollout (handle);
session->monitor_event (ZMQ_EVENT_CONNECT_DELAYED, endpoint.c_str(), zmq_errno());
socket->event_connect_delayed (endpoint.c_str(), zmq_errno());
}
// Handle any other error condition by eventual reconnect.
@@ -177,7 +178,7 @@ void zmq::tcp_connecter_t::add_reconnect_timer()
{
int rc_ivl = get_new_reconnect_ivl();
add_timer (rc_ivl, reconnect_timer_id);
session->monitor_event (ZMQ_EVENT_CONNECT_RETRIED, endpoint.c_str(), rc_ivl);
socket->event_connect_retried (endpoint.c_str(), rc_ivl);
timer_started = true;
}
@@ -303,6 +304,6 @@ void zmq::tcp_connecter_t::close ()
int rc = ::close (s);
errno_assert (rc == 0);
#endif
session->monitor_event (ZMQ_EVENT_CLOSED, endpoint.c_str(), s);
socket->event_closed (endpoint.c_str(), s);
s = retired_fd;
}