mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-31 14:39:55 +01:00
Merge pull request #371 from hurtonm/fix_race_condition_in_connecters
Fix race conditions in {tcp,ipc}_connecter
This commit is contained in:
commit
b448de926b
@ -59,13 +59,9 @@ zmq::ipc_connecter_t::ipc_connecter_t (class io_thread_t *io_thread_,
|
||||
|
||||
zmq::ipc_connecter_t::~ipc_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::ipc_connecter_t::process_plug ()
|
||||
@ -76,6 +72,24 @@ void zmq::ipc_connecter_t::process_plug ()
|
||||
start_connecting ();
|
||||
}
|
||||
|
||||
void zmq::ipc_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::ipc_connecter_t::in_event ()
|
||||
{
|
||||
// We are not polling for incomming data, so we are actually called
|
||||
|
@ -55,6 +55,7 @@ namespace zmq
|
||||
|
||||
// Handlers for incoming commands.
|
||||
void process_plug ();
|
||||
void process_term (int linger_);
|
||||
|
||||
// Handlers for I/O events.
|
||||
void in_event ();
|
||||
|
@ -52,8 +52,7 @@ zmq::ipc_listener_t::ipc_listener_t (io_thread_t *io_thread_,
|
||||
|
||||
zmq::ipc_listener_t::~ipc_listener_t ()
|
||||
{
|
||||
if (s != retired_fd)
|
||||
close ();
|
||||
zmq_assert (s == retired_fd);
|
||||
}
|
||||
|
||||
void zmq::ipc_listener_t::process_plug ()
|
||||
|
@ -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
|
||||
|
@ -53,6 +53,7 @@ namespace zmq
|
||||
|
||||
// Handlers for incoming commands.
|
||||
void process_plug ();
|
||||
void process_term (int linger_);
|
||||
|
||||
// Handlers for I/O events.
|
||||
void in_event ();
|
||||
|
@ -61,8 +61,7 @@ zmq::tcp_listener_t::tcp_listener_t (io_thread_t *io_thread_,
|
||||
|
||||
zmq::tcp_listener_t::~tcp_listener_t ()
|
||||
{
|
||||
if (s != retired_fd)
|
||||
close ();
|
||||
zmq_assert (s == retired_fd);
|
||||
}
|
||||
|
||||
void zmq::tcp_listener_t::process_plug ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user