Commit 7852a6ce authored by answeroo's avatar answeroo Committed by Luca Boccassi

PGM receiver crash fix (#3226)

Problem: PGM receiver can crash due to race

Solution: do not run in_event until restart_input finishes correctly.
Signed-off-by: 's avataransweroo <jiming@yafco.com>
parent 1c5e8178
......@@ -163,6 +163,11 @@ const char *zmq::pgm_receiver_t::get_endpoint () const
void zmq::pgm_receiver_t::in_event ()
{
// If active_tsi is not null, there is a pending restart_input.
// Keep the internal state as is so that restart_input would process the right data
if (active_tsi) {
return;
}
// Read data from the underlying pgm_socket.
const pgm_tsi_t *tsi = NULL;
......@@ -176,9 +181,10 @@ void zmq::pgm_receiver_t::in_event ()
while (true) {
// Get new batch of data.
// Note the workaround made not to break strict-aliasing rules.
insize = 0;
void *tmp = NULL;
ssize_t received = pgm_socket.receive (&tmp, &tsi);
inpos = (unsigned char *) tmp;
// No data to process. This may happen if the packet received is
// neither ODATA nor ODATA.
......@@ -212,6 +218,7 @@ void zmq::pgm_receiver_t::in_event ()
}
insize = static_cast<size_t> (received);
inpos = (unsigned char *) tmp;
// Read the offset of the fist message in the current packet.
zmq_assert (insize >= sizeof (uint16_t));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment