Commit 9cee8f9c authored by Martin Sustrik's avatar Martin Sustrik

problem with PGM messages larger than 1 MTU fixed

parent 27e47bdc
......@@ -93,12 +93,18 @@ void zmq::pgm_receiver_t::in_event ()
// Read data from the underlying pgm_socket.
unsigned char *data = NULL;
const pgm_tsi_t *tsi = NULL;
// TODO: This loop can effectively block other engines in the same I/O
// thread in the case of high load.
while (true) {
// Get new batch of data.
ssize_t received = pgm_socket.receive ((void**) &data, &tsi);
// No data to process. This may happen if the packet received is
// neither ODATA nor ODATA.
if (received == 0)
return;
break;
// Find the peer based on its TSI.
peers_t::iterator it = peers.find (*tsi);
......@@ -111,7 +117,7 @@ void zmq::pgm_receiver_t::in_event ()
delete it->second.decoder;
it->second.decoder = NULL;
}
return;
break;
}
// New peer. Add it to the list of know but unjoint peers.
......@@ -132,7 +138,7 @@ void zmq::pgm_receiver_t::in_event ()
// There is no beginning of the message in current packet.
// Ignore the data.
if (offset == 0xffff)
return;
continue;
zmq_assert (offset <= received);
zmq_assert (it->second.decoder == NULL);
......@@ -149,16 +155,14 @@ void zmq::pgm_receiver_t::in_event ()
it->second.decoder->set_inout (inout);
}
if (received) {
// Push all the data to the decoder.
// TODO: process_buffer may not process entire buffer!
ssize_t processed = it->second.decoder->process_buffer (data, received);
zmq_assert (processed == received);
}
// Flush any messages decoder may have produced.
inout->flush ();
}
}
#endif
......
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