mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 07:16:04 +00:00
Timers correctly canceled by PGM engines on shutdown.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
parent
e288f7a347
commit
b64b50ae21
@ -36,6 +36,7 @@
|
||||
zmq::pgm_receiver_t::pgm_receiver_t (class io_thread_t *parent_,
|
||||
const options_t &options_) :
|
||||
io_object_t (parent_),
|
||||
has_rx_timer (false),
|
||||
pgm_socket (true, options_),
|
||||
options (options_),
|
||||
inout (NULL),
|
||||
@ -81,7 +82,11 @@ void zmq::pgm_receiver_t::unplug ()
|
||||
mru_decoder = NULL;
|
||||
pending_bytes = 0;
|
||||
|
||||
// Stop polling.
|
||||
if (has_rx_timer) {
|
||||
cancel_timer (rx_timer_id);
|
||||
has_rx_timer = false;
|
||||
}
|
||||
|
||||
rm_fd (socket_handle);
|
||||
rm_fd (pipe_handle);
|
||||
|
||||
@ -150,8 +155,7 @@ void zmq::pgm_receiver_t::in_event ()
|
||||
// No data to process. This may happen if the packet received is
|
||||
// neither ODATA nor ODATA.
|
||||
if (received == 0) {
|
||||
const int last_errno = errno;
|
||||
if (last_errno == ENOMEM || last_errno == EBUSY) {
|
||||
if (errno == ENOMEM || errno == EBUSY) {
|
||||
const long timeout = pgm_socket.get_rx_timeout ();
|
||||
add_timer (timeout, rx_timer_id);
|
||||
has_rx_timer = true;
|
||||
|
@ -36,6 +36,8 @@
|
||||
zmq::pgm_sender_t::pgm_sender_t (io_thread_t *parent_,
|
||||
const options_t &options_) :
|
||||
io_object_t (parent_),
|
||||
has_tx_timer (false),
|
||||
has_rx_timer (false),
|
||||
encoder (0),
|
||||
pgm_socket (false, options_),
|
||||
options (options_),
|
||||
@ -89,6 +91,16 @@ void zmq::pgm_sender_t::plug (io_thread_t *io_thread_, i_inout *inout_)
|
||||
|
||||
void zmq::pgm_sender_t::unplug ()
|
||||
{
|
||||
if (has_rx_timer) {
|
||||
cancel_timer (rx_timer_id);
|
||||
has_rx_timer = false;
|
||||
}
|
||||
|
||||
if (has_tx_timer) {
|
||||
cancel_timer (tx_timer_id);
|
||||
has_tx_timer = false;
|
||||
}
|
||||
|
||||
rm_fd (handle);
|
||||
rm_fd (uplink_handle);
|
||||
rm_fd (rdata_notify_handle);
|
||||
@ -128,10 +140,9 @@ void zmq::pgm_sender_t::in_event ()
|
||||
has_rx_timer = false;
|
||||
}
|
||||
|
||||
// In event on sender side means NAK or SPMR receiving from some peer.
|
||||
// In-event on sender side means NAK or SPMR receiving from some peer.
|
||||
pgm_socket.process_upstream ();
|
||||
const int last_errno = errno;
|
||||
if (last_errno == ENOMEM || last_errno == EBUSY) {
|
||||
if (errno == ENOMEM || errno == EBUSY) {
|
||||
const long timeout = pgm_socket.get_rx_timeout ();
|
||||
add_timer (timeout, rx_timer_id);
|
||||
has_rx_timer = true;
|
||||
|
@ -66,7 +66,8 @@ namespace zmq
|
||||
enum {tx_timer_id = 0xa0, rx_timer_id = 0xa1};
|
||||
|
||||
// Timers are running.
|
||||
bool has_tx_timer, has_rx_timer;
|
||||
bool has_tx_timer;
|
||||
bool has_rx_timer;
|
||||
|
||||
// Message encoder.
|
||||
encoder_t encoder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user