mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-01 10:50:28 +08:00
problem with PGM messages larger than 1 MTU fixed
This commit is contained in:
parent
27e47bdcc0
commit
9cee8f9c3e
@ -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,17 +155,15 @@ 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user