Merge branch '1.4.10-openssl' into 1.4.15
This commit is contained in:
commit
bfdf940dbf
@ -92,6 +92,7 @@ GroupManager::GroupManager(const shared_ptr<VirtualServer> &server, sql::SqlMana
|
|||||||
GroupManager::~GroupManager() {}
|
GroupManager::~GroupManager() {}
|
||||||
|
|
||||||
bool GroupManager::loadGroupFormDatabase(GroupId id) {
|
bool GroupManager::loadGroupFormDatabase(GroupId id) {
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
if(id == 0){
|
if(id == 0){
|
||||||
this->groups.clear();
|
this->groups.clear();
|
||||||
|
|
||||||
@ -115,8 +116,13 @@ bool GroupManager::loadGroupFormDatabase(GroupId id) {
|
|||||||
|
|
||||||
std::vector<std::shared_ptr<Group>> GroupManager::availableGroups(bool root) {
|
std::vector<std::shared_ptr<Group>> GroupManager::availableGroups(bool root) {
|
||||||
std::vector<std::shared_ptr<Group>> response;
|
std::vector<std::shared_ptr<Group>> response;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
for(const auto& group : this->groups)
|
for(const auto& group : this->groups)
|
||||||
response.push_back(group);
|
response.push_back(group);
|
||||||
|
}
|
||||||
|
|
||||||
if(root && this->root){
|
if(root && this->root){
|
||||||
auto elm = this->root->availableGroups();
|
auto elm = this->root->availableGroups();
|
||||||
for(const auto& e : elm)
|
for(const auto& e : elm)
|
||||||
@ -127,9 +133,14 @@ std::vector<std::shared_ptr<Group>> GroupManager::availableGroups(bool root) {
|
|||||||
|
|
||||||
std::vector<std::shared_ptr<Group>> GroupManager::availableServerGroups(bool root){
|
std::vector<std::shared_ptr<Group>> GroupManager::availableServerGroups(bool root){
|
||||||
std::vector<std::shared_ptr<Group>> response;
|
std::vector<std::shared_ptr<Group>> response;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
for(const auto& group : this->groups)
|
for(const auto& group : this->groups)
|
||||||
if(group->target() == GroupTarget::GROUPTARGET_SERVER)
|
if(group->target() == GroupTarget::GROUPTARGET_SERVER)
|
||||||
response.push_back(group);
|
response.push_back(group);
|
||||||
|
}
|
||||||
|
|
||||||
if(root && this->root){
|
if(root && this->root){
|
||||||
auto elm = this->root->availableServerGroups();
|
auto elm = this->root->availableServerGroups();
|
||||||
for(const auto& e : elm)
|
for(const auto& e : elm)
|
||||||
@ -140,9 +151,12 @@ std::vector<std::shared_ptr<Group>> GroupManager::availableServerGroups(bool roo
|
|||||||
|
|
||||||
std::vector<std::shared_ptr<Group>> GroupManager::availableChannelGroups(bool root) {
|
std::vector<std::shared_ptr<Group>> GroupManager::availableChannelGroups(bool root) {
|
||||||
std::vector<std::shared_ptr<Group>> response;
|
std::vector<std::shared_ptr<Group>> response;
|
||||||
|
{
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
for(const auto& group : this->groups)
|
for(const auto& group : this->groups)
|
||||||
if(group->target() == GroupTarget::GROUPTARGET_CHANNEL)
|
if(group->target() == GroupTarget::GROUPTARGET_CHANNEL)
|
||||||
response.push_back(group);
|
response.push_back(group);
|
||||||
|
}
|
||||||
if(root && this->root){
|
if(root && this->root){
|
||||||
auto elm = this->root->availableChannelGroups(true);
|
auto elm = this->root->availableChannelGroups(true);
|
||||||
for(const auto& e : elm)
|
for(const auto& e : elm)
|
||||||
@ -237,6 +251,7 @@ void GroupManager::handleChannelDeleted(const ChannelId& channel_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GroupManager::isLocalGroup(std::shared_ptr<Group> gr) {
|
bool GroupManager::isLocalGroup(std::shared_ptr<Group> gr) {
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
return std::find(this->groups.begin(), this->groups.end(), gr) != this->groups.end();
|
return std::find(this->groups.begin(), this->groups.end(), gr) != this->groups.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,9 +267,12 @@ std::shared_ptr<Group> GroupManager::defaultGroup(GroupTarget type, bool enforce
|
|||||||
auto group = this->findGroupLocal(id);
|
auto group = this->findGroupLocal(id);
|
||||||
if(group || enforce_property) return group;
|
if(group || enforce_property) return group;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
for(auto elm : this->groups)
|
for(auto elm : this->groups)
|
||||||
if(elm->target() == type)
|
if(elm->target() == type)
|
||||||
return elm;
|
return elm;
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr; //Worst case!
|
return nullptr; //Worst case!
|
||||||
}
|
}
|
||||||
@ -266,6 +284,7 @@ std::shared_ptr<Group> GroupManager::findGroup(GroupId groupId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Group> GroupManager::findGroupLocal(GroupId groupId) {
|
std::shared_ptr<Group> GroupManager::findGroupLocal(GroupId groupId) {
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
for(const auto& elm : this->groups)
|
for(const auto& elm : this->groups)
|
||||||
if(elm->groupId() == groupId) return elm;
|
if(elm->groupId() == groupId) return elm;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -273,8 +292,11 @@ std::shared_ptr<Group> GroupManager::findGroupLocal(GroupId groupId) {
|
|||||||
|
|
||||||
std::vector<std::shared_ptr<Group>> GroupManager::findGroup(GroupTarget target, std::string name) {
|
std::vector<std::shared_ptr<Group>> GroupManager::findGroup(GroupTarget target, std::string name) {
|
||||||
vector<shared_ptr<Group>> res;
|
vector<shared_ptr<Group>> res;
|
||||||
|
{
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
for(const auto &elm : this->groups)
|
for(const auto &elm : this->groups)
|
||||||
if(elm->name() == name && elm->target() == target) res.push_back(elm);
|
if(elm->name() == name && elm->target() == target) res.push_back(elm);
|
||||||
|
}
|
||||||
if(this->root) {
|
if(this->root) {
|
||||||
auto r = root->findGroup(target, name);
|
auto r = root->findGroup(target, name);
|
||||||
for(const auto &e : r) res.push_back(e);
|
for(const auto &e : r) res.push_back(e);
|
||||||
@ -305,6 +327,8 @@ std::shared_ptr<Group> GroupManager::createGroup(GroupTarget target, GroupType t
|
|||||||
std::shared_ptr<Group> group = std::make_shared<Group>(this, target, type, groupId);
|
std::shared_ptr<Group> group = std::make_shared<Group>(this, target, type, groupId);
|
||||||
group->properties()[property::GROUP_NAME] = name;
|
group->properties()[property::GROUP_NAME] = name;
|
||||||
group->setPermissionManager(serverInstance->databaseHelper()->loadGroupPermissions(this->server.lock(), group->groupId()));
|
group->setPermissionManager(serverInstance->databaseHelper()->loadGroupPermissions(this->server.lock(), group->groupId()));
|
||||||
|
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
this->groups.push_back(group);
|
this->groups.push_back(group);
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
@ -394,7 +418,10 @@ bool GroupManager::deleteGroup(std::shared_ptr<Group> group) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard glock{this->group_lock};
|
||||||
this->groups.erase(std::find(this->groups.begin(), this->groups.end(), group));
|
this->groups.erase(std::find(this->groups.begin(), this->groups.end(), group));
|
||||||
|
}
|
||||||
|
|
||||||
/* erase the group out of our cache */
|
/* erase the group out of our cache */
|
||||||
{
|
{
|
||||||
|
@ -224,7 +224,10 @@ namespace ts {
|
|||||||
ServerId getServerId();
|
ServerId getServerId();
|
||||||
|
|
||||||
sql::SqlManager* sql;
|
sql::SqlManager* sql;
|
||||||
|
|
||||||
|
std::mutex group_lock{};
|
||||||
std::vector<std::shared_ptr<Group>> groups;
|
std::vector<std::shared_ptr<Group>> groups;
|
||||||
|
|
||||||
threads::Mutex cacheLock;
|
threads::Mutex cacheLock;
|
||||||
std::vector<std::shared_ptr<CachedClient>> cachedClients;
|
std::vector<std::shared_ptr<CachedClient>> cachedClients;
|
||||||
|
|
||||||
|
@ -758,9 +758,9 @@ bool VirtualServer::notifyServerEdited(std::shared_ptr<ConnectedClient> invoker,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VirtualServer::notifyClientPropertyUpdates(std::shared_ptr<ConnectedClient> client, const deque<const property::PropertyDescription*>& keys, bool selfNotify) {
|
bool VirtualServer::notifyClientPropertyUpdates(std::shared_ptr<ConnectedClient> client, const deque<const property::PropertyDescription*>& keys, bool selfNotify) {
|
||||||
if(keys.empty()) return false;
|
if(keys.empty() || !client) return false;
|
||||||
this->forEachClient([&](const shared_ptr<ConnectedClient>& cl) {
|
this->forEachClient([&](const shared_ptr<ConnectedClient>& cl) {
|
||||||
shared_lock client_channel_lock(client->channel_lock);
|
shared_lock client_channel_lock(cl->channel_lock);
|
||||||
if(cl->isClientVisible(client, false) || (cl == client && selfNotify))
|
if(cl->isClientVisible(client, false) || (cl == client && selfNotify))
|
||||||
cl->notifyClientUpdated(client, keys, false);
|
cl->notifyClientUpdated(client, keys, false);
|
||||||
});
|
});
|
||||||
|
2
shared
2
shared
@ -1 +1 @@
|
|||||||
Subproject commit f404d5e1fa5ed1cfbe3ef9a97c0e81c1fba943ff
|
Subproject commit 246e57e69d61d25d92e76c2af0368eac18536ac1
|
Loading…
Reference in New Issue
Block a user