Fixed some stuff

This commit is contained in:
WolverinDEV
2019-07-19 22:16:27 +02:00
parent 5c41277871
commit 26007a51c4
2 changed files with 10 additions and 4 deletions
@@ -487,13 +487,17 @@ void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length,
if(head) /* head packet */
packet->enable_flag(ts::protocol::PacketFlag::Compressed);
this->protocol_handler->send_packet(packet);
if((rand() % 10) < 2) {
log_info(category::connection, tr("Dropping voice packet"));
} else {
this->protocol_handler->send_packet(packet);
}
}
void ServerConnection::close_connection() {
if(this_thread::get_id() == this->socket->io_thread().get_id()) {
lock_guard lock(this->disconnect_lock);
if(this->socket && this_thread::get_id() == this->socket->io_thread().get_id()) {
logger::debug(category::connection, tr("close_connection() called in IO thread. Closing connection within event loop!"));
lock_guard lock(this->disconnect_lock);
if(!this->event_loop_execute_connection_close) {
this->event_loop_execute_connection_close = true;
this->event_condition.notify_one();
@@ -501,7 +505,6 @@ void ServerConnection::close_connection() {
return;
}
lock_guard lock(this->disconnect_lock);
this->event_loop_execute_connection_close = false;
if(this->socket) {
this->socket->finalize();