mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
filter out overlarge frames
This commit is contained in:
parent
88d1ee7836
commit
8d8a4cf620
@ -247,10 +247,15 @@ transmit_frame_data(int thread_index) {
|
||||
|
||||
datagram.add_uint16(thread_index);
|
||||
datagram.add_uint32(thread->_frame_number);
|
||||
thread->_frame_data.write_datagram(datagram);
|
||||
|
||||
bool sent;
|
||||
if (_writer.is_valid_for_udp(datagram)) {
|
||||
|
||||
if (!thread->_frame_data.write_datagram(datagram, _client)) {
|
||||
// Too many events to fit in a single datagram. Maybe it was
|
||||
// a long frame load or something. Just drop the datagram.
|
||||
sent = false;
|
||||
|
||||
} else if (_writer.is_valid_for_udp(datagram)) {
|
||||
if (_udp_count * _udp_count_factor < _tcp_count * _tcp_count_factor) {
|
||||
// Send this one as a UDP packet.
|
||||
nassertv(_got_udp_port);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "pStatFrameData.h"
|
||||
#include "pStatClientVersion.h"
|
||||
#include "config_pstats.h"
|
||||
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
@ -39,11 +40,19 @@ sort_time() {
|
||||
// Function: PStatFrameData::write_datagram
|
||||
// Access: Public
|
||||
// Description: Writes the definition of the FrameData to the
|
||||
// datagram.
|
||||
// datagram. Returns true on success, false on failure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatFrameData::
|
||||
write_datagram(Datagram &destination) const {
|
||||
bool PStatFrameData::
|
||||
write_datagram(Datagram &destination, PStatClient *client) const {
|
||||
Data::const_iterator di;
|
||||
if (_time_data.size() >= 65536 || _level_data.size() >= 65536) {
|
||||
pstats_cat.info()
|
||||
<< "Dropping frame with " << _time_data.size()
|
||||
<< " time measurements and " << _level_data.size()
|
||||
<< " level measurements.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
destination.add_uint16(_time_data.size());
|
||||
for (di = _time_data.begin(); di != _time_data.end(); ++di) {
|
||||
destination.add_uint16((*di)._index);
|
||||
@ -54,6 +63,8 @@ write_datagram(Datagram &destination) const {
|
||||
destination.add_uint16((*di)._index);
|
||||
destination.add_float32((*di)._value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -28,6 +28,7 @@
|
||||
class Datagram;
|
||||
class DatagramIterator;
|
||||
class PStatClientVersion;
|
||||
class PStatClient;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PStatFrameData
|
||||
@ -62,7 +63,7 @@ public:
|
||||
INLINE int get_level_collector(int n) const;
|
||||
INLINE float get_level(int n) const;
|
||||
|
||||
void write_datagram(Datagram &destination) const;
|
||||
bool write_datagram(Datagram &destination, PStatClient *client) const;
|
||||
void read_datagram(DatagramIterator &source, PStatClientVersion *version);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user