Fixed a crash
This commit is contained in:
@@ -96,11 +96,12 @@ void VoiceClientConnection::handle_incoming_datagram(const pipes::buffer_view& b
|
||||
unique_lock queue_lock(fragment_buffer.buffer_lock);
|
||||
auto result = fragment_buffer.accept_index(packet_parser.packet_id());
|
||||
if(result != 0) { /* packet index is ahead buffer index */
|
||||
debugMessage(this->client->getServerId(), "{} Dropping command packet because command assembly buffer has an {} ({}|{})",
|
||||
debugMessage(this->client->getServerId(), "{} Dropping command packet because command assembly buffer has an {} ({}|{}|{})",
|
||||
CLIENT_STR_LOG_PREFIX_(this->client),
|
||||
result == -1 ? "underflow" : "overflow",
|
||||
fragment_buffer.capacity(),
|
||||
fragment_buffer.current_index()
|
||||
fragment_buffer.current_index(),
|
||||
packet_parser.packet_id()
|
||||
);
|
||||
|
||||
if(result == -1) { /* underflow */
|
||||
@@ -227,7 +228,8 @@ void VoiceClientConnection::execute_handle_command_packets(const std::chrono::sy
|
||||
//TODO: Remove the buffer_execute_lock and use the one within the this->client->handlePacketCommand method
|
||||
unique_lock<std::recursive_timed_mutex> buffer_execute_lock;
|
||||
pipes::buffer payload{};
|
||||
auto reexecute_handle = this->next_reassembled_command(buffer_execute_lock, payload);
|
||||
uint16_t packet_id{};
|
||||
auto reexecute_handle = this->next_reassembled_command(buffer_execute_lock, payload, packet_id);
|
||||
|
||||
if(!payload.empty()){
|
||||
auto startTime = system_clock::now();
|
||||
@@ -255,7 +257,7 @@ void VoiceClientConnection::execute_handle_command_packets(const std::chrono::sy
|
||||
}
|
||||
|
||||
/* buffer_execute_lock: lock for in order execution */
|
||||
bool VoiceClientConnection::next_reassembled_command(unique_lock<std::recursive_timed_mutex>& buffer_execute_lock, pipes::buffer& result) {
|
||||
bool VoiceClientConnection::next_reassembled_command(unique_lock<std::recursive_timed_mutex>& buffer_execute_lock, pipes::buffer& result, uint16_t& packet_id) {
|
||||
command_fragment_buffer_t* buffer{nullptr};
|
||||
unique_lock<std::recursive_timed_mutex> buffer_lock; /* general buffer lock */
|
||||
|
||||
@@ -290,9 +292,11 @@ bool VoiceClientConnection::next_reassembled_command(unique_lock<std::recursive_
|
||||
pipes::buffer payload{};
|
||||
|
||||
/* lets find out if we've to reassemble the packet */
|
||||
if(buffer->slot_value(0).packet_flags & PacketFlag::Fragmented) {
|
||||
uint16_t sequence_length = 1;
|
||||
size_t total_payload_length{0};
|
||||
auto& first_buffer = buffer->slot_value(0);
|
||||
packet_id = first_buffer.packet_id;
|
||||
if(first_buffer.packet_flags & PacketFlag::Fragmented) {
|
||||
uint16_t sequence_length{1};
|
||||
size_t total_payload_length{first_buffer.payload_length};
|
||||
do {
|
||||
if(sequence_length >= buffer->capacity()) {
|
||||
logError(this->client->getServerId(), "{} Command fragment buffer is full, and there is not fragmented packet end. Dropping full buffer which will probably cause a connection loss.", CLIENT_STR_LOG_PREFIX_(this->client));
|
||||
@@ -320,7 +324,7 @@ bool VoiceClientConnection::next_reassembled_command(unique_lock<std::recursive_
|
||||
|
||||
pipes::buffer packet_buffer{total_payload_length};
|
||||
char* packet_buffer_ptr = &packet_buffer[0];
|
||||
size_t packet_count = 0;
|
||||
size_t packet_count{0};
|
||||
|
||||
packet_flags = buffer->slot_value(0).packet_flags;
|
||||
while(packet_count < sequence_length) {
|
||||
@@ -340,6 +344,7 @@ bool VoiceClientConnection::next_reassembled_command(unique_lock<std::recursive_
|
||||
);
|
||||
}
|
||||
#endif
|
||||
payload = packet_buffer;
|
||||
} else {
|
||||
auto packet = buffer->pop_front();
|
||||
packet_flags = packet.packet_flags;
|
||||
@@ -415,7 +420,7 @@ bool VoiceClientConnection::prepare_packet_for_write(vector<pipes::buffer> &resu
|
||||
|
||||
string error = "success";
|
||||
|
||||
if(packet->type().compressable() && !packet->memory_state.fragment_entry && false) {
|
||||
if(packet->type().compressable() && !packet->memory_state.fragment_entry) {
|
||||
packet->enable_flag(PacketFlag::Compressed);
|
||||
if(!this->compress_handler.progressPacketOut(packet.get(), error)) {
|
||||
logError(this->getClient()->getServerId(), "{} Could not compress outgoing packet.\nThis could cause fatal failed for the client.\nError: {}", error);
|
||||
|
||||
Reference in New Issue
Block a user