pstats: Server can handle new protocol version 2.3

It changes the following things:
* Changes the counts in the PStatFrameData from uint16 to uint32, since I was hitting the value limit in some heavy frames with Python profiling enabled - no good reason for this limitation, so this allows removing it later
* Adds a T_expire_thread message, which I can use later to fix #450

These features are not used on the client side, but will be used on master.  Adding these changes here now makes it possible to use a master client with a 1.10.13 version of the server (can be useful if you can't compile Panda on the host).
This commit is contained in:
rdb 2022-12-10 19:28:03 +01:00
parent 3254c6d329
commit fb14c29525
5 changed files with 28 additions and 4 deletions

View File

@ -60,6 +60,10 @@ encode(Datagram &datagram) const {
}
break;
case T_expire_thread:
datagram.add_uint16(_first_thread_index);
break;
default:
pstats_cat.error()
<< "Invalid PStatClientControlMessage::Type " << (int)_type << "\n";
@ -111,6 +115,10 @@ decode(const Datagram &datagram, PStatClientVersion *version) {
}
break;
case T_expire_thread:
_first_thread_index = source.get_uint16();
break;
case T_datagram:
// Not, strictly speaking, a control message.
return false;

View File

@ -39,6 +39,7 @@ public:
T_hello,
T_define_collectors,
T_define_threads,
T_expire_thread,
T_invalid
};

View File

@ -106,11 +106,16 @@ write_datagram(Datagram &destination, PStatClient *client) const {
* Extracts the FrameData definition from the datagram.
*/
void PStatFrameData::
read_datagram(DatagramIterator &source, PStatClientVersion *) {
read_datagram(DatagramIterator &source, PStatClientVersion *version) {
clear();
{
size_t time_size = source.get_uint16();
size_t time_size;
if (version->is_at_least(3, 2)) {
time_size = source.get_uint32();
} else {
time_size = source.get_uint16();
}
_time_data.resize(time_size);
for (DataPoint &dp : _time_data) {
nassertv(source.get_remaining_size() > 0);
@ -120,7 +125,12 @@ read_datagram(DatagramIterator &source, PStatClientVersion *) {
}
{
size_t level_size = source.get_uint16();
size_t level_size;
if (version->is_at_least(3, 2)) {
level_size = source.get_uint32();
} else {
level_size = source.get_uint16();
}
_level_data.resize(level_size);
for (DataPoint &dp : _level_data) {
nassertv(source.get_remaining_size() > 0);

View File

@ -31,6 +31,7 @@ static const int current_pstat_minor_version = 0;
// Incremented to 2.1 on 5/21/01 to add support for TCP frame data.
// Incremented to 3.0 on 4/28/05 to bump TCP headers to 32 bits.
// Incremented to 3.1 on 11/29/22 to support nested start/stop pairs.
// Incremented to 3.2 on 12/10/22 to use 32-bit data counts, T_expire_thread.
/**
* Returns the current major version number of the PStats protocol. This is

View File

@ -194,7 +194,7 @@ handle_client_control_message(const PStatClientControlMessage &message) {
if (message._major_version != server_major_version ||
(message._major_version == server_major_version &&
message._minor_version > server_minor_version &&
(message._major_version != 3 || message._minor_version != 1))) {
(message._major_version != 3 || message._minor_version > 2))) {
_monitor->bad_version(message._client_hostname, message._client_progname,
message._major_version, message._minor_version,
server_major_version, server_minor_version);
@ -225,6 +225,10 @@ handle_client_control_message(const PStatClientControlMessage &message) {
}
break;
case PStatClientControlMessage::T_expire_thread:
// Ignore for now.
break;
default:
nout << "Invalid control message received from client.\n";
}