don't crash when the system includes more than 1400 collectors

This commit is contained in:
David Rose 2005-02-23 22:06:34 +00:00
parent 33c2803608
commit 5181b69662

View File

@ -365,11 +365,21 @@ report_new_collectors() {
nassertv(_is_connected); nassertv(_is_connected);
if (_collectors_reported < (int)_client->_collectors.size()) { if (_collectors_reported < (int)_client->_collectors.size()) {
// Empirically, we determined that you can't send more than about
// 1400 collectors at once without exceeding the 64K limit on a
// single datagram. So we limit ourselves here to sending only
// half that many.
static const int max_collectors_at_once = 700;
while (_collectors_reported < (int)_client->_collectors.size()) {
PStatClientControlMessage message; PStatClientControlMessage message;
message._type = PStatClientControlMessage::T_define_collectors; message._type = PStatClientControlMessage::T_define_collectors;
while (_collectors_reported < (int)_client->_collectors.size()) { int i = 0;
while (_collectors_reported < (int)_client->_collectors.size() &&
i < max_collectors_at_once) {
message._collectors.push_back(_client->get_collector_def(_collectors_reported)); message._collectors.push_back(_client->get_collector_def(_collectors_reported));
_collectors_reported++; _collectors_reported++;
i++;
} }
Datagram datagram; Datagram datagram;
@ -377,6 +387,7 @@ report_new_collectors() {
_writer.send(datagram, _tcp_connection); _writer.send(datagram, _tcp_connection);
} }
} }
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: PStatClientImpl::report_new_threads // Function: PStatClientImpl::report_new_threads