Fixed build

This commit is contained in:
WolverinDEV
2019-07-06 15:38:31 +02:00
parent bbeeecbc61
commit c790c8bd08
14 changed files with 76 additions and 34 deletions
@@ -141,6 +141,8 @@ void ServerConnection::event_loop() {
auto best = this->next_tick;
if(this->next_resend < best)
best = this->next_resend;
if(this->event_loop_execute_connection_close)
return system_clock::time_point{};
return best;
};
@@ -157,6 +159,10 @@ void ServerConnection::event_loop() {
if(this->event_loop_exit)
break;
}
if(this->event_loop_execute_connection_close) {
this->close_connection();
this->event_loop_execute_connection_close = false;
}
auto date = chrono::system_clock::now();
if(this->next_tick <= date) {
this->next_tick = date + chrono::milliseconds(500);
@@ -485,10 +491,22 @@ void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length,
}
void ServerConnection::close_connection() {
if(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();
}
return;
}
lock_guard lock(this->disconnect_lock);
if(this->socket)
this->event_loop_execute_connection_close = false;
if(this->socket) {
this->socket->finalize();
this->protocol_handler->close_connection();
}
this->protocol_handler->do_close_connection();
this->socket = nullptr;
this->call_disconnect_result.call(0, true);
}