fixed query select bug

This commit is contained in:
WolverinDEV 2019-08-13 11:04:00 +02:00
parent 942ea44e90
commit bd43c53db2
2 changed files with 160 additions and 147 deletions

View File

@ -186,7 +186,7 @@ target_link_libraries(PermHelper
SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "3") SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "22") SET(CPACK_PACKAGE_VERSION_PATCH "23")
if(BUILD_TYPE_NAME EQUAL OFF) if(BUILD_TYPE_NAME EQUAL OFF)
SET(CPACK_PACKAGE_VERSION_DATA "beta") SET(CPACK_PACKAGE_VERSION_DATA "beta")
elseif(BUILD_TYPE_NAME STREQUAL "") elseif(BUILD_TYPE_NAME STREQUAL "")

View File

@ -125,11 +125,6 @@ CommandResult QueryClient::handleCommandExit(Command &) {
return CommandResult::Success; return CommandResult::Success;
} }
struct QuerySqlData {
std::string username;
std::string password;
std::string uniqueId;
};
//login client_login_name=andreas client_login_password=meinPW //login client_login_name=andreas client_login_password=meinPW
CommandResult QueryClient::handleCommandLogin(Command& cmd) { CommandResult QueryClient::handleCommandLogin(Command& cmd) {
CMD_RESET_IDLE; CMD_RESET_IDLE;
@ -174,11 +169,11 @@ CommandResult QueryClient::handleCommandLogin(Command& cmd) {
this->query_account = account; this->query_account = account;
auto joined = this->currentChannel; auto joined_channel = this->currentChannel;
if(this->server) { if(this->server) {
{ {
unique_lock tree_lock(this->server->channel_tree_lock); unique_lock tree_lock(this->server->channel_tree_lock);
if(joined) if(joined_channel)
this->server->client_move(this->ref(), nullptr, nullptr, "", ViewReasonId::VREASON_USER_ACTION, false, tree_lock); this->server->client_move(this->ref(), nullptr, nullptr, "", ViewReasonId::VREASON_USER_ACTION, false, tree_lock);
this->server->unregisterClient(_this.lock(), "login", tree_lock); this->server->unregisterClient(_this.lock(), "login", tree_lock);
} }
@ -194,6 +189,8 @@ CommandResult QueryClient::handleCommandLogin(Command& cmd) {
auto target_server = this->server; /* keep the server alive 'ill we've joined the server */ auto target_server = this->server; /* keep the server alive 'ill we've joined the server */
if(account->bound_server) { if(account->bound_server) {
target_server = serverInstance->getVoiceServerManager()->findServerById(account->bound_server); target_server = serverInstance->getVoiceServerManager()->findServerById(account->bound_server);
if(target_server != this->server)
joined_channel = nullptr;
if(!target_server) if(!target_server)
return {findError("server_invalid_id"), "server does not exists anymore"}; return {findError("server_invalid_id"), "server does not exists anymore"};
} }
@ -204,22 +201,30 @@ CommandResult QueryClient::handleCommandLogin(Command& cmd) {
target_server->groups->enableCache(_this.lock()); target_server->groups->enableCache(_this.lock());
target_server->registerClient(_this.lock()); target_server->registerClient(_this.lock());
{
shared_lock server_tree_lock(target_server->channel_tree_lock); shared_lock server_tree_lock(target_server->channel_tree_lock);
if(joined_channel) /* needs only notify if we were already on that server within a channel */
target_server->notifyClientPropertyUpdates(_this.lock(), deque<property::ClientProperties>{property::CLIENT_NICKNAME, property::CLIENT_UNIQUE_IDENTIFIER}); target_server->notifyClientPropertyUpdates(_this.lock(), deque<property::ClientProperties>{property::CLIENT_NICKNAME, property::CLIENT_UNIQUE_IDENTIFIER});
shared_lock client_tree_lock(this->channel_lock); unique_lock client_tree_lock(this->channel_lock);
this->channels->reset(); this->channels->reset();
this->channels->insert_channels(target_server->channelTree->tree_head(), true, false); this->channels->insert_channels(target_server->channelTree->tree_head(), true, false);
this->subscribeChannel(this->server->channelTree->channels(), false, false);
}
if(joined_channel) {
unique_lock tree_lock(this->server->channel_tree_lock);
if(joined_channel)
this->server->client_move(this->ref(), joined_channel, nullptr, "", ViewReasonId::VREASON_USER_ACTION, false, tree_lock);
} else if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_virtualserver_select_godmode, 1))
this->server->assignDefaultChannel(this->ref(), true);
else
this->update_cached_permissions();
} else { } else {
serverInstance->getGroupManager()->enableCache(_this.lock()); serverInstance->getGroupManager()->enableCache(_this.lock());
this->update_cached_permissions(); this->update_cached_permissions();
} }
if(target_server) {
unique_lock tree_lock(target_server->channel_tree_lock);
if(joined)
this->server->client_move(this->ref(), joined, nullptr, "", ViewReasonId::VREASON_USER_ACTION, false, tree_lock);
}
this->properties()[property::CLIENT_TOTALCONNECTIONS]++; this->properties()[property::CLIENT_TOTALCONNECTIONS]++;
this->updateChannelClientProperties(true, true); this->updateChannelClientProperties(true, true);
@ -251,19 +256,26 @@ CommandResult QueryClient::handleCommandLogout(Command &) {
this->server->groups->enableCache(_this.lock()); this->server->groups->enableCache(_this.lock());
this->server->registerClient(this->ref()); this->server->registerClient(this->ref());
{
shared_lock server_channel_r_lock(this->server->channel_tree_lock); shared_lock server_channel_r_lock(this->server->channel_tree_lock);
unique_lock client_channel_lock(this->channel_lock); unique_lock client_channel_lock(this->channel_lock);
this->channels->reset(); this->channels->reset();
this->channels->insert_channels(this->server->channelTree->tree_head(), true, false); this->channels->insert_channels(this->server->channelTree->tree_head(), true, false);
client_channel_lock.unlock(); this->subscribeChannel(this->server->channelTree->channels(), false, false);
server_channel_r_lock.unlock(); }
if(joined) { if(joined) {
unique_lock server_channel_w_lock(this->server->channel_tree_lock, defer_lock); unique_lock server_channel_w_lock(this->server->channel_tree_lock, defer_lock);
this->server->client_move(this->ref(), joined, nullptr, "", ViewReasonId::VREASON_USER_ACTION, false, server_channel_w_lock); this->server->client_move(this->ref(), joined, nullptr, "", ViewReasonId::VREASON_USER_ACTION, false, server_channel_w_lock);
} else if(!this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_virtualserver_select_godmode, 1)) {
this->server->assignDefaultChannel(this->ref(), true);
} else {
this->update_cached_permissions();
} }
} else { } else {
serverInstance->getGroupManager()->enableCache(_this.lock()); serverInstance->getGroupManager()->enableCache(_this.lock());
this->update_cached_permissions();
} }
this->updateChannelClientProperties(true, true); this->updateChannelClientProperties(true, true);
@ -312,7 +324,8 @@ CommandResult QueryClient::handleCommandServerSelect(Command &cmd) {
} }
server_locked->groups->disableCache(_this.lock()); server_locked->groups->disableCache(_this.lock());
this->channels->reset(); this->channels->reset();
} else serverInstance->getGroupManager()->disableCache(_this.lock()); } else
serverInstance->getGroupManager()->disableCache(_this.lock());
} }
this->resetEventMask(); this->resetEventMask();
@ -333,11 +346,11 @@ CommandResult QueryClient::handleCommandServerSelect(Command &cmd) {
{ {
shared_lock server_channel_lock(target->channel_tree_lock); shared_lock server_channel_lock(target->channel_tree_lock);
unique_lock client_channel_lock(this->channel_lock); unique_lock client_channel_lock(this->channel_lock);
this->subscribeToAll = true; this->subscribeToAll = true;
this->channels->insert_channels(this->server->channelTree->tree_head(), true, false); this->channels->insert_channels(this->server->channelTree->tree_head(), true, false);
this->subscribeChannel(this->server->channelTree->channels(), false, true); this->subscribeChannel(this->server->channelTree->channels(), false, false);
} }
auto negated_enforce_join = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_virtualserver_select_godmode, 1); auto negated_enforce_join = this->permissionGranted(permission::PERMTEST_ORDERED, permission::b_virtualserver_select_godmode, 1);