Fix race conditions in {tcp,ipc}_connecter

Once the object has been terminated, it is unsafe for this object
to refer to its parent.

The bug was responsible for occasional
test_shutdown_stress failures.
This commit is contained in:
Martin Hurton
2012-06-12 01:39:16 +02:00
parent e9bfd76f87
commit 3ec8e576d9
6 changed files with 46 additions and 18 deletions

View File

@@ -69,13 +69,9 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
zmq::tcp_connecter_t::~tcp_connecter_t ()
{
if (wait)
cancel_timer (reconnect_timer_id);
if (handle_valid)
rm_fd (handle);
if (s != retired_fd)
close ();
zmq_assert (!wait);
zmq_assert (!handle_valid);
zmq_assert (s == retired_fd);
}
void zmq::tcp_connecter_t::process_plug ()
@@ -86,6 +82,24 @@ void zmq::tcp_connecter_t::process_plug ()
start_connecting ();
}
void zmq::tcp_connecter_t::process_term (int linger_)
{
if (wait) {
cancel_timer (reconnect_timer_id);
wait = false;
}
if (handle_valid) {
rm_fd (handle);
handle_valid = false;
}
if (s != retired_fd)
close ();
own_t::process_term (linger_);
}
void zmq::tcp_connecter_t::in_event ()
{
// We are not polling for incomming data, so we are actually called