diff --git a/server/src/client/voice/PacketEncoder.cpp b/server/src/client/voice/PacketEncoder.cpp index 4b051a5..25737e1 100644 --- a/server/src/client/voice/PacketEncoder.cpp +++ b/server/src/client/voice/PacketEncoder.cpp @@ -62,6 +62,9 @@ void PacketEncoder::send_packet(ts::protocol::OutgoingServerPacket *packet) { packet->set_packet_id(full_id & 0xFFFFU); packet->generation = full_id >> 16U; + auto category = stats::ConnectionStatistics::category::from_type(packet->packet_type()); + this->callback_connection_stats(this->callback_data, category, packet->packet_length() + 96); /* 96 for the UDP packet overhead */ + { std::lock_guard qlock{this->write_queue_mutex}; *this->encrypt_queue_tail = packet; @@ -69,9 +72,6 @@ void PacketEncoder::send_packet(ts::protocol::OutgoingServerPacket *packet) { } this->callback_request_write(this->callback_data); - - auto category = stats::ConnectionStatistics::category::from_type(packet->packet_type()); - this->callback_connection_stats(this->callback_data, category, packet->packet_length() + 96); /* 96 for the UDP packet overhead */ } void PacketEncoder::send_packet(protocol::PacketType type, protocol::PacketFlag::PacketFlags flag, const void *payload, size_t payload_size) { @@ -216,8 +216,9 @@ void PacketEncoder::send_command(const std::string_view &command, bool low, std: } this->callback_request_write(this->callback_data); - if(own_data_buffer) + if(own_data_buffer) { ::free(own_data_buffer_ptr); + } } void PacketEncoder::encrypt_pending_packets() {