Fixed the default channel group assignment

This commit is contained in:
WolverinDEV
2021-04-12 19:12:02 +02:00
parent 3aa50a2c1a
commit bf643b4797
3 changed files with 27 additions and 21 deletions
+14 -14
View File
@@ -409,6 +409,11 @@ void VirtualServer::delete_channel(shared_ptr<ts::ServerChannel> channel, const
}
}
/*
* This method had previously owned the clients command lock but that's not really needed.
* Everything which is related to the server channel tree or the client channel tree should be locked with
* the appropiate mutexes.
*/
void VirtualServer::client_move(
const shared_ptr<ts::server::ConnectedClient> &target,
shared_ptr<ts::BasicChannel> target_channel,
@@ -419,32 +424,27 @@ void VirtualServer::client_move(
std::unique_lock<std::shared_mutex> &server_channel_write_lock) {
TIMING_START(timings);
if(server_channel_write_lock.owns_lock()) {
if(!server_channel_write_lock.owns_lock()) {
server_channel_write_lock.unlock();
}
lock_guard client_command_lock(target->command_lock);
server_channel_write_lock.lock();
TIMING_STEP(timings, "chan tree l");
if(target->currentChannel == target_channel) {
return;
}
/* first step: resolve the target channel / or fix missing */
/* first step: verify thew source and target channel */
auto s_target_channel = dynamic_pointer_cast<ServerChannel>(target_channel);
auto s_source_channel = dynamic_pointer_cast<ServerChannel>(target->currentChannel);
assert(!target->currentChannel || s_source_channel != nullptr);
deque<property::ClientProperties> client_updates;
std::deque<property::ClientProperties> changed_groups{};
std::deque<property::ClientProperties> updated_client_properties{};
if(target_channel) {
assert(s_target_channel);
if(s_target_channel->deleted) {
target_channel = this->channelTree->getDefaultChannel();
s_target_channel = dynamic_pointer_cast<ServerChannel>(target_channel);
assert(s_target_channel);
return;
}
}
auto l_target_channel = s_target_channel ? this->channelTree->findLinkedChannel(s_target_channel->channelId()) : nullptr;
auto l_source_channel = s_source_channel ? this->channelTree->findLinkedChannel(s_source_channel->channelId()) : nullptr;
TIMING_STEP(timings, "channel res");
@@ -559,9 +559,9 @@ void VirtualServer::client_move(
target->properties()[property::CLIENT_IS_TALKER] = 0;
target->properties()[property::CLIENT_TALK_REQUEST] = 0;
target->properties()[property::CLIENT_TALK_REQUEST_MSG] = "";
client_updates.push_back(property::CLIENT_IS_TALKER);
client_updates.push_back(property::CLIENT_TALK_REQUEST);
client_updates.push_back(property::CLIENT_TALK_REQUEST_MSG);
updated_client_properties.push_back(property::CLIENT_IS_TALKER);
updated_client_properties.push_back(property::CLIENT_TALK_REQUEST);
updated_client_properties.push_back(property::CLIENT_TALK_REQUEST_MSG);
}
TIMING_STEP(timings, "src chan up");
}
@@ -600,7 +600,7 @@ void VirtualServer::client_move(
}
client_channel_lock.unlock();
/* both methods lock if they require stuff */
this->notifyClientPropertyUpdates(target, client_updates, s_source_channel ? true : false);
this->notifyClientPropertyUpdates(target, updated_client_properties, s_source_channel ? true : false);
TIMING_STEP(timings, "notify cpro");
if(s_target_channel) {
target->updateChannelClientProperties(false, s_source_channel ? true : false);