diff --git a/server/src/client/voice/VoiceClient.cpp b/server/src/client/voice/VoiceClient.cpp index 6c1c0a4..db74d5b 100644 --- a/server/src/client/voice/VoiceClient.cpp +++ b/server/src/client/voice/VoiceClient.cpp @@ -171,8 +171,9 @@ bool VoiceClient::close_connection(const system_clock::time_point &timeout) { { std::lock_guard state_lock{this->state_lock}; - if(this->state == ConnectionState::DISCONNECTED) return false; - else if(this->state == ConnectionState::DISCONNECTING) { + if(this->state == ConnectionState::DISCONNECTED) { + return false; + } else if(this->state == ConnectionState::DISCONNECTING) { /* here is nothing to pay attention for */ } else if(this->state == ConnectionState::DISCONNECTING_FLUSHING) { if(!flush) { @@ -188,6 +189,10 @@ bool VoiceClient::close_connection(const system_clock::time_point &timeout) { debugMessage(this->getServerId(), "{} Closing voice client connection. (Flush: {})", CLIENT_STR_LOG_PREFIX, flush); //TODO: Move this out into a thread pool? + if(this->flushing_thread->joinable()) { + logCritical(LOG_GENERAL, "VoiceClient::close_connection reached flushing thread with an active old handle. Ignoring request."); + return true; + } this->flushing_thread = std::make_shared([this, self_lock, timeout, flush]{ {